It is common that you don’t want hi-res original images uploaded to your Uploadcare account. Doing so is inefficient on both ends:
- Sending large images over mobile networks can be expensive for your users.
- Large images take up your account storage limit and delivering those increase your traffic.
The option is passed into your widget as a string holding your preferred resolution and, optionally, a JPEG quality of the resulting image. The preferred resolution you provide does not affect original image aspect ratio.
Image Shrink outputs to:
- JPEG in case an input image has no transparency.
- PNG in case an input image includes transparent pixels.
Here are some examples of values you can specify for
control the feature:
800x600, shrinks images to 0.48 megapixels with the default JPEG quality of 80%.
1600x1600 95%, shrinks images to 2.5 megapixels with the JPEG quality set to 95%.
The resolution you set for optimized images should not exceed 5 megapixels. All EXIF info from your original images will be copied to the resized ones. The copied EXIF info includes image orientation, camera model, geolocation, and settings.
Input images will not be optimized in the following cases:
- When a client browser does not support all the required APIs.
- When images are uploaded from social media or URLs.
- If the
original resolution / target resolutionratio falls behind
2.0. For example, you can not shrink a 2560x1560px (4 MP) image to 1600x1600px (2.5 MP) while this works with a 2448x3264px (8 MP) original. The reason we implemented this limit is to preserve an optimal balance between a decline in quality and drop in file size.
<input type="hidden" role="uploadcare-uploader" name="my_file" data-preview-step="" data-image-shrink="1024x1024" />
<input type="hidden" role="uploadcare-uploader" name="my_files" data-multiple="" data-image-shrink="640x480" />