![]() ![]() Preserving metadata will not count as an extra compression. Metadata adds to the compressed file size, so you should only preserve Location and the creation date are currently supported. Preserving copyright information, the GPS You can request that specific metadata is copied from the uploaded image To an image type which does not support transparency (like JPEG). You must specify a background color if you wish to convert an image with a transparent background Only the colors white and black are supported as strings. Custom background color using the color's hex value: "#000000". The following options are availableĪ hex value. Include a background property to fill a transparent image's background. The transform object specifies the stylistic transformations that will be applied to your image. The wildcard "*/*" returns the smallest of Tinify's supported image types, currently WebP, JPEG and PNG. Smallest of the provided image types will be returned. Multiple image types, specified as an array. One image type, specified as a string "image/webp". The following options are available as a type: You can provide the following options to convert your image: convert $converted->toFile( "panda-sticker.jpg") $source = \Tinify\fromFile( "panda-sticker.png") The background of a transparent image will be filled. Specify a background property in the transform object. If you wish to convert an image with a transparent background to one with a solid background, In case you want to include formats that do not support transparency (JPEG), one can specify a background color that replaces the transparency using the transform object. Images with a transparent background will only be converted to formats that support transparency. $extension = $converted->result()->extension() $converted = $source->convert( array( "type" => )) $source = \Tinify\fromFile( "panda-sticker.jpg") Image converting will count as one additional compression. When you provide more than one image type in your convert request, the smallest version will be returned to you. Tinify currently supports converting between WebP, JPEG, and PNG. You can use the API to convert your images to your desired image type. Scaling up is prevented in order to protect the If the target dimensions are larger than the original dimensions, the image If an image is detected with aįree standing object it will add more background space where The followingĪ more advanced implementation of cover that also detects cut out The method describes the way your image will be resized. To resize an image, call the resize method on an image source: $source = \Tinify\fromFile( "large.jpg") This will count as 3 compressions in total. For example, if you uploadĪ single image and retrieve the optimized version plus 2 resized versions Resizing counts as one additional compression. That focus on the most visually important areas of your image. You can also take advantage of intelligent cropping to create thumbnails Optimally compressed with a nice and crisp appearance. You will only have to upload your image once. The API handle resizing you avoid having to write such code yourself and Use the API to create resized versions of your uploaded images. You can provide a URL to your image instead of having to upload it. $resultData = \Tinify\fromBuffer($sourceData)->toBuffer() $sourceData = file_get_contents( "unoptimized.jpg") You can also upload an image from a buffer (a string with binary) and get $source = \Tinify\fromFile( "unoptimized.webp") You can choose a local file as the source and write it to another file. Compression will start as soon as you upload a Will automatically detect the type of image and optimise with the TinyPNG or You can upload any WebP, JPEG or PNG image to the Tinify API to compress it. Set the URL of your proxy server, which can optionally include credentials. You can instruct the API client to make all requests over an HTTP proxy. Always keep your API key secret! \Tinify\setKey( "YOUR_API_KEY") Īll requests will be made over an encrypted Get an API key by registering with your name andĮmail address. To use the API you must provide your API key. Require_once( "lib/Tinify/ResultMeta.php") require_once( "lib/Tinify/Exception.php") Include them in your project as shown below. If you do not like to use Composer you can also manually install theįrom Github, extract the files to a folder of your choice and Make sure to require Composer’s autoloader: require_once( "vendor/autoload.php") You can use the PHP client by installing theĪnd adding it to your application’s dependencies: composer require tinify/tinify Languages make it very easy to interact with the Tinify API. The Tinify API allows you to compress and optimize WebP, JPEG and PNG images. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |