Filestack now offers a standalone task specifically for compression. It utilizes mozjpeg to offer improved compression for jpgs over the algorithm used for output=compress:true. It will not attempt to re-compress a previously compressed image. Compress will only work with png and jpg files. If any other format is passed in, it will return an unchanged image. For the best results, compress should be the last task in your transformation chain.

Note: The maximum accepted image size is 100,000,000 pixels. An image with this many pixels could have width and height combinations like 10,000 x 10,000 or 5,000 x 20,000, etc. There is also a file size restriction. Filestack will not convert an image that is larger than 256mb. Please contact us if you require the ability to process larger files than our current limits.


Compress URL Format:[options]/Filestack_FileLink_Handle

The root task cannot be abbreviated

Users can use compress without any options and the default settings will be used.

Can be abbreviated as m:true

By default the compress task will strip photo metadata out of the image to reduce the file size. If you need to maintain the file metadata, you can pass metadata:true in order to prevent the metadata from being removed.

Compress Examples

Original Image

Original Image of Hamilton 2016 Monaco

By Andrew Locking -, Link

The original image is 5.9mb and has dimensions of 4740x3160. By running it through the compress task, we can reduce its size.

Image using all the default settings compress:

This action reduces the size of the file by 4%, but depending on the image, the size reduction can be far greater.

If you are standardizing your images by resizing them to a specific size, you can additionally add in the compress task to further optimize them.

Image resized to a width of 1000 using resize=w:1000

This reduced the file size to 318kb. However, we can achieve a greater reduction in size by combining the resize with the compression task. It should be the last task passed in your URL, otherwise the image will be compressed before it gets resized.

Image resized to a width of 1000 and then compressed using resize=w:1000/compress/

The end result is an image that is 276.6kb. Which is a 13% reduction in file size from the 318kb image.

If we decide we want to maintain the metadata:

Image resized and compressed while keeping the file metadata resize=w:1000/compress=metadata:true/

Then the transformed image is 296.4kb