I'm looking to turn off compression for product pages specifically, meaning if I uploaded a 200k jpeg file, I expect to see exactly the same 200k file on a product page.

Looking to find a line that governs said compression. Looked into other similar questions but the answers didn't work for me at all.

Magento generates a lot of jpegs based on that original 200k one, but I'm looking to completely bypass those cached images and display the original one instead.


1 Answer 1


Image size options are configured in the theme's /etc/view.xml file. I believe that image compression is handled by Fastly image optimization.

This fine answer describes the benefits of overriding the vendor/magento/module-catalog/Model/Product/Image.php and vendor/magento/module-catalog/Model/Product/Image/ParamsBuilder.php files for improved images in Magento 2.

  • Not sure it's exactly what I was looking for. Setting compression level to 100 will simply make the images larger than the originals, what I need to do is bypass the compression algorithm (for just the product page) entirely and output images exactly as they were uploaded - their md5 hashes (for example) would be the same. Sep 5, 2022 at 9:32
  • @ЗахарJoe Yes, I worded my answer carefully to emphasize that this is not the exact answer you asked for, but it is an answer that addresses the problem.
    – dotancohen
    Sep 5, 2022 at 10:44
  • It doesn't quite address the problem, because you either end up with images that look bad and are small, or images that look almost as good and way larger than the originals. I understand Magento's logic there, if you upload original, say, TIFF or PNG files then it makes sense to convert them to JPEGs with a certain compression level. Trouble is, our images were already JPEG compressed for production and we lost the uncompressed originals. Sep 5, 2022 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.