This article covers:
- How to change default product image sizes in Magento 2 product image cache
- How to resolve Magento 2’s aggressive image compression
The server environment:
- Apache 2.4, Ubuntu 18.04
- Magento 2.2.6 upgraded to 2.3.0
- Used imagemagick instead of GD2
Step 1 – Increase Maximum Allowed Image Size
Firstly you need to understand two factors come into play to image quality:- Maximum Image size allowed
- Image compression
Step 2 – Adjust Product Image Size in view.xml
Product image sizes are controlled in your theme file (one of the many good reasons why child theme is a must-have for Magento 2):{vendor}/{child_theme}/etc/view.xml
After the first step, I noticed my 238kb product image was heavily compressed into 70.1kb (full-screen gallery), and 32kb (main product image), which is outrageous! So compression rate has a more significant impact on image quality.
Step 3 – Adjust Image Compression Level
Now here comes the most confusing part: in most threads out there people recommend to change or rewrite this core file:vendor/magento/module-catalog/Model/Product/Image.phpAbove is incorrect because it never worked! I found changing the settings from 80 to 100 in below file finally killed the beast:
vendor/magento/module-catalog/Model/Product/Image/ParamsBuilder.phpOnce I figured out how to write a module instead of modifying core files, I will update this article accordingly.
Conclusion
Magento team should consider making image compression level adjustable in admin, just like they did with the max image size in the 2.3 release. There are plenty of store owners out there have no issues with spending bucks on the server, and they certainly don’t want the eCommerce platform itself to become the limitation for user experience. What’s more important than high-quality product images?To many, a business is a lifetime commitment. It's easy to start one yet difficult to make it successful. Attitude, skills, experiences and dedication help hone the craft along the way, but it's often the great vision and resilience to remain focused wins the game. Read more about me here
This article covers: How to add website switcher in a multi-website environmentHow…
This article covers: How to generate CSR (certificate signing request), which is…
SEO is an area where too many eCommerce startups cannot help to…
Testing remains a critical stage for eCommerce developing, and it should be…
At the very beginning when we first start eCommerce developing, we came…
Ever since we started eCommerce developing, we often found it's hard to…
Your design must be suitable for your audiences The most cutting-edge design…
Brands are human creations, therefore, bear characteristic of the creators, in other…