Download the PHP package vormkracht10/php-uploadcare-transformations without Composer

On this page you can find all versions of the php package vormkracht10/php-uploadcare-transformations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-uploadcare-transformations

Easy Uploadcare Image Transformation URLs generation

Total Downloads Tests PHPStan GitHub release (latest by date) Packagist PHP Version Support Latest Version on Packagist

Generate Uploadcare image processing URLs to transform and process your images. No need to write or generate the URL yourself. Just pass the UUID of the file, optionally pass the custom CDN and chain the methods you want to apply and the package generates the URL for you.

Requirements

Installation

You can install the package via composer:

Usage

  1. Import UploadcareTransformation.
  2. Get the UUID of the file you want to show.
  3. Set your CDN url (optional).
  4. Create the transformation URL by chaining one or multiple methods to the UploadcareTransformation class. You can chain as much methods as you want.
  5. Use the output of the transformation as image source.

If you prefer to use a shorter version you can also use the helper method:

Using the Laravel framework

When you are using the Laravel framework it might be better to define the CDN in your .env file and get the value from the .env file in a config file. You can create a dedicated config/uploadcare config or add it to the config/services file.

Your .env file:

Add to config/services.php file:

In your code:

Documentation

Using percentages or pixels as parameter

In some of the methods you can pass parameters in various ways. For example in the scaleCrop() method you can pass the offset in the form of a percentage or pixels. To make it easier to recognize when a pixel or percentage is used you can pass the parameters as following.

As stated in the Uploadcare Documentation, in URLs, % is an escape character and should be encoded with %25 escape sequence, e.g. /scale_crop/440x440/80%25,80%25/. For convenience, we can use the p shortcut for percent which doesn't require encoding.

List of possible transformations

Each transformation follows the documentation on Uploadcare which you may find here. The current list of possible transformations and where to find the documentation:

Transformation Uploadcare Documentation link
Auto rotate Link
Basic color adjustments Link
Blur Link
Blur faces Link
Blur region Link
Convert to sRGB Link
Crop Link
Crop by objects Link
Crop by ratio Link
Enhance Link
Filter Link
Flip Link
Format Link
Grayscale Link
ICC profile size threshold Link
Invert Link
Miror Link
Overlay Link
Preview Link
Progressive Link
Quality Link
Rasterize Link
Resize Link
Rotate Link
Scale crop Link
Set fill Link
Sharpen Link
Smart crop Link
Smart resize Link
Zoom objects Link

Usage

Adding filename

Original filenames can be accessed via Uploadcare's REST API. This can be done by making a request to receive a JSON response with file parameters including original_filename.

You can set an optional filename that users will see instead of the original name:

Please note that the filename should comply with file name conventions. For more more information about how to use filenames please check the Uploadcare API documentation.

Auto rotate

The default behavior goes with parsing EXIF tags of original images and rotating them according to the “Orientation” tag. Using false as parameter allows turning off the default behavior.

Basic color adjustments

The value parameter controls the strength of any applied adjustment. Ranges of the value parameter differ between operations. There also is a zero point for each operation — the value producing outputs equal to original images.

Adjustment (color) must be one of the following values: brightness, exposure, contrast, saturation, gamma, vibrance, warmth.

For a complete overview of allowed values based upon the chosen adjustment, take a look at the Uploadcare Documentation.

Blur

Blurs images by the strength factor. The filtering mode is Gaussian Blur, where strength parameter sets the blur radius — effect intensity.

Blur faces

When faces is specified the regions are selected automatically by utilizing face detection.

Blur region

Blurs the specified region of the image by the strength factor. The filtering mode is Gaussian Blur, where strength parameter sets the blur radius — effect intensity.

Dimensions and coordinates must be pixels or percentages.

Convert to sRGB

The operation sets how Uploadcare behaves depending on different color profiles of uploaded images. See the Uploadcare Documentation to learn more about the possible outcomes.

The profile parameter must be one of the following values: fast, icc, keep_profile.

Crop

Crops an image by using specified dimensions and alignment.

Dimensions parameters can be in pixels or percentages. To see how pixels or percentages can be used, see the Using percentages or pixels as parameter paragraph.

Alignment can also be in pixels and percentages but also a shortcut can be used. The possible values are: top, center, bottom, left, right.

Crop by objects

Crops the image to the object specified by the tag parameter.

Tag can be one of face or image.

Ratio are two numbers greater than zero separated by :. Ratio is the quotient from the division of these numbers.

Dimensions and alignment must be set in percentages. In case of the alignment you can also use the shortcut. The possible values are: top, center, bottom, left, right. If alignment is not specified, center value is used.

Dimensions should be relative when used with a tag. So you are required to set both width and height with pixels.

Crop by ratio

Crops the image to the specified aspect ratio, cutting off the rest of the image.

Ratio are two numbers greater than zero separated by :. Ratio is the quotient from the division of these numbers.

Alignment can be set in pixels and percentages but also a shortcut can be used. The possible values are: top, center, bottom, left, right. If alignment is not specified, center value is used.

Enhance

Auto-enhances an image by performing the following operations: auto levels, auto contrast, and saturation sharpening.

Strength must be a number between 0 and 100. Default value is 50.

Filter

Applies one of predefined photo filters by its name. The way your images look affects their engagement rates. You apply filters thus providing beautiful images consistent across content pieces you publish.

The name parameter should be one of the following: adaris, briaril, calarel, carris, cynarel, cyren, elmet, elonni, enzana, erydark, fenralan, ferand, galen, gavin, gethriel, iorill, iothari, iselva, jadis, lavra, misiara, namala, nerion, nethari, pamaya, sarnar, sedis, sewen, sorahel, sorlen, tarian, thellassan, varriel, varven, vevera, virkas, yedis, yllara, zatvel, zevcen.

The amount parameter must be a number between -100 and 200.

Flip

Flips images.

Format

Converts an image to one of the following formats: jpg, png, webp, auto.

Grayscale

Desaturates images. The operation has no additional parameters and simply produces a grayscale image output when applied.

ICC profile size threshold

The operation defines which RGB color profile sizes will be considered “small” and “large” when using srgb in fast or icc modes. The number stands for the ICC profile size in kilobytes.

The default value is 10 (10240 bytes). Most of the common RGB profile sizes (sRGB, Display P3, ProPhoto, Adobe RGB, Apple RGB) are below the threshold.

Please note, that because this transformation should always be used in combination with convertToSRGB() its method should be called after convertToSRGB(). Otherwise the ICC profile size threshold gets overwritten by the convertToSRGB() transformation.

Invert

Inverts images rendering a 'negative' of the input.

Miror

Mirrors images.

Overlay

The overlay operation allows to layer images one over another. One of the most common use cases here are watermarks: semi-transparent images layered over opaque ones to complicate their unauthorized usage, etc.

Every overlay parameter is optional and can be omitted. However, the order of parameter URL directives should be preserved. For example, if you want to use coordinateX parameter, you should also specify width and height parameters. Also note that the opacity parameter should be specified with percentages.

Preview

Downscales an image proportionally to fit the given width and height in pixels.

Progressive

Returns a progressive image. In progressive images, data are compressed in multiple passes of progressively higher detail. The operation does not affect non-JPEG images; does not force image formats to JPEG.

Quality

Sets output JPEG and WebP quality. Since actual settings vary from codec to codec, and more importantly, from format to format, we provide five simple tiers and two automatic values which suits most cases of image distribution and are consistent.

Quality must be one of the following values: smart, smart_retina, normal, better, best, lighter, lightest.

Rasterize

Rasterize SVG images.

Resize

Resizes an image to one or two dimensions. When you set both width and height explicitly, it may result in a distorted image. If you specify either side, this operation will preserve the original aspect ratio and resize the image accordingly. Mode should be one of the following values: on, off, fill.

`

Rotate

Right-angle image rotation, counterclockwise. The value of angle must be a multiple of 90.

Scale crop

Scales an image until it fully covers the specified dimensions; the rest gets cropped. Mostly used to place images with various dimensions into placeholders (e.g., square shaped).

Dimensions must be set in pixels.

Alignment must be set in percentages or shortcut. The possible values are: top, center, bottom, left, right. If alignment is not specified, 0,0 value is used.

Set fill

Sets the fill color used with crop, stretch or when converting an alpha channel enabled image to JPEG.

Color must be a hex color code without using the hashtag.

Sharpen

Sharpens an image, might be especially useful with images that were subjected to downscaling. strength can be in the range from 0 to 20 and defaults to the value of 5.

Smart crop

Switching the crop type to one of the smart modes enables the content-aware mechanics. Uploadcare applies AI-based algorithms to detect faces and other visually sensible objects to crop the background and not the main object.

Dimensions must be set in pixels.

Type must be one of the following values: smart, smart_faces_objects, smart_faces, smart_objects, smart_faces_points, smart_points, smart_objects_faces_points, smart_objects_points or smart_objects_faces.

Aligment must be set in percentages or shortcut. The possible values are: top, center, bottom, left, right. If alignment is not specified, 0,0 value is used.

Smart resize

Content-aware resize helps retaining original proportions of faces and other visually sensible objects while resizing the rest of the image using intelligent algorithms.

Zoom objects

Zoom objects operation is best suited for images with solid or uniform backgrounds.

Zoom must be a number between 1 and 100.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of php-uploadcare-transformations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vormkracht10/php-uploadcare-transformations contains the following files

Loading the files please wait ....