Last updated: Jun-04-2024
q_auto
) instead.Cloudinary is a cloud-based service that provides an end-to-end image management solution including uploads, storage, transformations, optimizations and delivery.
Cloudinary offers a very rich set of image transformation and optimization capabilities. Cloudinary seamlessly applies advanced image size shrinking logic to make sure that your images are as small as possible without degrading their viewing quality. In addition, Cloudinary's image transformation supports controlling the JPG quality level in order to control the balance between image file size and display quality.
JPEGmini is a patent-pending JPEG photo optimization technology, which significantly reduces the size of photographs without affecting their perceptual quality. Cloudinary provides an add-on for using JPEGmini's image optimization capabilities, fully integrated into Cloudinary's image management and transformation pipeline.
With JPEGmini's image optimization add-on, you can extend Cloudinary's powerful image transformation and optimization capabilities by automatically converting images to their best matching quality for faster delivery. When using the JPEGmini add-on, your images will be automatically optimized using advanced visual algorithms achieving file size reduction while maintaining a very high visual quality.
(For simplicity, most of the examples on this page show eagerly generated URLs without signatures.)
Getting started
Before you can use the JPEGmini Image Optimization add-on:
You must have a Cloudinary account. If you don't already have one, you can sign up for a free account.
Register for the add-on: make sure you're logged in to your account and then go to the Add-ons page. For more information about add-on registrations, see Registering for add-ons.
Keep in mind that many of the examples on this page use our SDKs. For SDK installation and configuration details, see the relevant SDK guide.
If you're new to Cloudinary, you may want to take a look at the Developer Kickstart for a hands-on, step-by-step introduction to Programmable Media features.
Using JPEGmini
Before you start, if you haven't done so already, please sign-up for a Free account. After signing up, you can try the JPEGmini image optimization add-on for free and later on register for an add-on plan that best matches your usage requirements.
Take a look at the following 'brown_sheep' photo that was uploaded to Cloudinary. This image file weighs 207KB.
JPEG images can be created with different quality levels. There's a trade-off between the desired reduction in file size and the deterioration in photo quality. Most websites prefer to aim at high quality of all displayed images, therefore they usually embed JPG images of about 90% quality. However, lower quality may still be adequate for different images.
The Cloudinary URL below dynamically converts the image to the best matching JPG quality using the JPEGmini add-on. While the original and smartly converted images look the same, the JPEGmini optimized one weighs just 115KB. This means that we saved 44% of the original image size. Less bytes mean faster loading time, better user experience and reduced bandwidth costs.
Signed URLs
Cloudinary's dynamic image transformation URLs are quite powerful and enable agile web and mobile development. However, due to the potential costs of users accessing unplanned dynamic URLs with JPEGmini quality directives, image transformation add-on URLs are required (by default) to be signed using Cloudinary's authenticated API and with the sign_url
parameter set to true
.
The following code example generates a 200x150 resized version of the 'brown_sheep' image with a signed Cloudinary URL and the quality
transformation parameter set to jpegmini
. The generated Cloudinary URL includes a signature component s--ERIdO8k8--
. Only URLs with a valid signature that matches the requested image transformation will be approved for on-the-fly image transformation and delivery.
For more details on signed URLs, see the following blog post: On-the-fly image transformations secured with signed URLs.
Eager transformations
As an alternative to signed URLs, you can eagerly generate all converted images during upload. This way you already use Cloudinary's authenticated API for requesting JPEGmini image optimization, therefore, accessing the generated images can be done using regular unsigned Cloudinary URLs.
The following code sample uploads a local JPG file to Cloudinary, assigns a custom public ID and eagerly generates the same 200x150 thumbnail that was smartly optimized using JPEGmini as in the signed-URL example above.
Learn more: Upload presets
The resized and optimized image is available for delivery immediately when the upload request completes. Therefore, the optimized version can be accessed using an unsigned URL as in the example below:
Optimize JPG images
Optimizing JPG images using the JPEGmini add-on is done by setting the quality
transformation parameter to jpegmini
. Smart image conversion can be applied on the resulting image following any image scaling. The following resized and optimized image is generated on the fly by Cloudinary and delivered cached via a fast CDN. The size of the optimized thumbnail is 24.9KB, which is 27% less than the 34KB of the non JPEGmini optimized image.
The default jpegmini
quality gives you the best possible quality while still providing a significantly smaller file size than the original.
If optimizing file size is more important than visual quality, you can request high (1) or medium (2) level quality instead of best (0), by adding the quality level value to the parameter, using the syntax: jpegmini:level
.
For example, to request high quality (23.2 KB):
Further image transformations
Smart image optimization using the JPEGmini Cloudinary add-on can be mixed with any of Cloudinary's rich set of image transformation capabilities.
For example, the following code first scales the 'horses' image to a width of 400 pixels while rounding its corners and increasing color saturation by 50%. Then another uploaded image named 'logo_jpegmini' is added as an overlay. The overlay is resized to a width of 100 pixels, positioned 10 pixels from the bottom right corner of the containing image and is made 80% semi-transparent. Finally, the automatic JPEGmini quality conversion is applied on the resulting image: