We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more by reading our Privacy Policy.
Image Optimizer for Magento
Optimize your images, reduce their file size without losing image quality, and speed up your site.
Magento 2 Current Extension Version: 2.2.8
Compatibility
Open Source (CE): 2.0, 2.1, 2.2, 2.3, 2.4
Commerce using on-prem (EE): 2.2, 2.3, 2.4
Commerce on Cloud (ECE): 2.2, 2.3, 2.4
Compatible with Breeze
Compatible with Hyvä
Magento 1 Current Extension Version: 2.2.4
Compatibility
Open Source (CE): 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7, 1.8, 1.8.1, 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4
Commerce using on-prem (EE): 1.10, 1.11, 1.11.1, 1.12, 1.13, 1.13.1, 1.14, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.9.0.0, 1.9.1.0, 1.9.2.0
OpenMage LTS: 19, 20
Compatible with Breeze frontend!
Compatible with Hyvä frontend!
Speed Up Your Magento Site For Free!
Works great with Minify HTML CSS JS (also FREE)!
Compatible with both Magento v2 and Magento v1!
(Two separate versions of the extension. One for Magento v2 and one for Magento v1.)
Apptrian Image Optimizer will optimize your images (GIF, JPG, PNG), reduce their file size without losing image quality, and speed up your site. The extension is very easy to install and use. You can optimize images by clicking a button in Magento Admin or automatically by a configurable cron job. If you are an advanced user you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. (By default our extension is using optimization utilities recommended by Google PageSpeed Insights and GTmetrix.)
Image Optimizer is fully compatible with Google Perceptual JPEG encoder "guetzli"
However, you need to:
1. Install guetzli on your server.
This is not covered by our Installation and Support services. More info on how to install guetzli can be found here.
2. Configure our extension to use guetzli.
In our extension config in the "Utility" section
For "JPG Utility" type guetzli
For "JPG Utility Exact Path" type full path where you installed guetzli or if you added it to the system path then type only the name of the binary it should be guetzli
For "JPG Utility Options" type:
--quality 90 %filepath% %filepath%
you can adjust the quality option to your liking.
3. Test optimization by using test images we provided and manually compare file size before and after optimization. (Configuring and testing guetzli is covered by our Installation and Support services.)
Be aware of the following:
Guetzli is a "lossy" compressor. This means you will lose some image quality. (By default our extension is using jpegtran and there is no change in image quality after optimization.)
Guetzli is much slower than jpegran.
IMPORTANT NOTICE
In order to pass the Google PageSpeed Insights test regarding image optimization Google Perceptual JPEG encoder "guetzli" is required.
Use GTmetrix to check your image optimization status.
Warning! Before using our extension on real images you must test optimization utilities. (Please follow configuration and testing instructions.)
Warning! Extension relays on third-party utilities (gifsicle, jpegoptim (32-bit only), jpegtran, and optipng). It is also highly dependent on a server type and configuration. There is a possibility it will not work for you. Please understand that there is no PHP code we can write that will make previously mentioned utilities work if they are not compatible with your server nor circumvent your server configuration.
Our extension will NOT change the visual quality of the images if you use jpegtran which is used by default. However, it will degrade image quality if you use a "lossy" compressor like guetzli.
Our extension will NOT change the resolution of the images.
Our extension is only the last step in the image optimization that will help you to pass Google PageSpeed Insights and GTmetrix test, it is not the substitution for best practices regarding the preparation of images for the web.
Before uploading images to the web (in this case Magento) you need to prepare them. This is a wide subject but the most important things are:
- Choose the right format for the image (gif, jpg, png) (Read the FAQs for more information)
- Choose the right resolution for the image (Read the FAQs for more information)
Compatible with Breeze frontend without the need for an additional compatibility module. It works out of the box.
Compatible with Hyvä frontend without the need for an additional compatibility module. It works out of the box.
Features
General
- An easy way to enable or disable the extension.
- The "Batch Size" is the number of images to be optimized per click or cron execution.
- The "Paths" option is a text area field where you can type paths you want to be scanned for images.
- Convenient "Start Scan and Reindex Process" button for scanning and reindexing images.
- Convenient "Start Optimization Process" button for optimizing images.
- Convenient Progress Bar will give you info about the percentage and number of optimized images.
- Convenient "Clear Index" button for resetting progress bar and ability to start index and optimization processes again.
Cron
- An easy way to enable or disable the Scan and Reindex Process Cron Job.
- Option to type Cron Expression for the Scan and Reindex Process.
- An easy way to enable or disable the Optimization Process Cron Job.
- Option to type Cron Expression for the Optimization Process.
Utility
- The "Use 64-bit Utilities" option will allow you to run the 64-bit version of utilities.
- Log Utility Output option allows you to log information about the optimization process.
- Force file permissions after optimization.
- The "Utilities Path" option allows you to swap optimization utilities.
- GIF Utility allows you to set GIF optimization utility.
- GIF Utility Exact Path allows you to specify the path to your GIF utility if it is already installed on your system.
- GIF Utility Options allows you to set GIF utility options.
- JPG Utility allows you to set JPG optimization utility.
- JPG Utility Exact Path allows you to specify the path to your JPG utility if it is already installed on your system.
- JPG Utility Options allows you to set JPG utility options.
- PNG Utility allows you to set PNG optimization utility.
- PNG Utility Exact Path allows you to specify the path to your PNG utility if it is already installed on your system.
- PNG Utility Options allows you to set PNG utility options.
Installation Instructions (For Magento v2)
There are several ways you can install any Magento extension. Our extension is no different. We will show you four ways to install the extension, but you must not mix them. Choose one and stick to it.
If you do not know how to install an extension or you wish a professional to do it for you, we offer an additional installation service for a small fee.
Installation via file uploading
(If you purchased the extension on our site)
If you purchased the extension on our site then unpack .zip file from /Magento2/InstallByUploadingFiles/ directory inside your Magento root.
- Run following commands on Magento root directory:
php bin/magento maintenance:enable
php bin/magento module:enable --clear-static-content Apptrian_ImageOptimizer
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento setup:static-content:deploy
php bin/magento maintenance:disable
php bin/magento cache:flush
Installation via Composer
(If you purchased the extension on our site)
If you purchased the extension on our site and you want to install the extension via composer public and private keys. (To find your public and private keys, login to your Apptrian.com customer account and look at the My Downloadable Products section.)
- Run following commands on Magento root directory:
php bin/magento maintenance:enable
composer config --auth http-basic.packages.apptrian.com $PUBLIC_KEY $PRIVATE_KEY
composer config repositories.apptrian-image-optimizer composer https://packages.apptrian.com/image-optimizer/
composer require apptrian/image-optimizer
php bin/magento module:enable --clear-static-content Apptrian_ImageOptimizer
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento setup:static-content:deploy
php bin/magento maintenance:disable
php bin/magento cache:flush
Installation via Composer by using artifact
(If you purchased the extension on our site)
If you purchased the extension on our site then copy .zip file from /Magento2/InstallWithComposer/ directory inside your MAGENTO_ROOT/vendor/apptrian/packages/ directory (create directory if does not exist).
- Run following commands on Magento root directory:
php bin/magento maintenance:enable
composer config repositories.apptrianartifacts artifact $(pwd)/vendor/apptrian/packages
composer require apptrian/image-optimizer
php bin/magento module:enable --clear-static-content Apptrian_ImageOptimizer
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento setup:static-content:deploy
php bin/magento maintenance:disable
php bin/magento cache:flush
Installation via Composer
(If you purchased the extension on Magento Marketplace)
If you purchased the extension on Magento Marketplace then you must use Composer. Magento Marketplace does not allow extension downloads.
- Run following commands on Magento root directory:
php bin/magento maintenance:enable
composer require apptrian/image-optimizer
php bin/magento module:enable --clear-static-content Apptrian_ImageOptimizer
php bin/magento setup:upgrade
php bin/magento cache:flush
php bin/magento setup:static-content:deploy
php bin/magento maintenance:disable
php bin/magento cache:flush
Please make sure your Magento public and private keys are in your Magento root auth.json file. Usually, people install Magento with one Magento Marketplace account (public and private keys) and then purchase an extension with another Magento Marketplace account (different public and private keys). Check the Magento Marketplace account you used to purchase the extension and make sure its public and private keys are in the Magento root auth.json file. WARNING! if you already have keys there, be very careful because maybe some other extensions are purchased with another Magento Marketplace account.
If you do not know how to install an extension or you wish a professional to do it for you, we offer an additional Installation service for a small fee.
(If you purchase Installation Service please contact us via the contact form on our site and state your full name and order ID)
Installation Instructions (For Magento v1)
- Log in to Magento Admin
- (Optional) Disable Magento Compiler if you are using it (System > Tools > Compilation)
- Go to System > Magento Connect > Magento Connect Manager
- If you purchased an extension on our site use "Direct package file upload" and upload the .tgz file
- If you purchased an extension on Magento Marketplace use "Install New Extensions" and paste the extension URL key
- Go back to Magento Admin
- Refresh Magento cache (System > Cache Management), then log out from Magento Admin and log back in
- (Optional) Enable Magento Compiler by clicking "Run Compilation Process" button (System > Tools > Compilation)
- Set execute permissions on files inside lib/Apptrian/ImageOptimizer
- If you already have gifsicle, jpegtran, and optipng installed on your server use "Utility Exact Path" fields to point extension to your installed versions of these utilities.
If you do not know how to install an extension or you wish a professional to do it for you, we offer an additional Installation service for a small fee.
(If you purchase Installation Service please contact us via the contact form on our site and state your full name and order ID)
Configuration and Testing Instructions
Please test the extension before you use it!
Download testimages.zip file (inside are test images that are not optimized). Unpack the testimages.zip file into your Magento root. Then in our extension configuration for the option "Paths" remove everything and type "testimages". Click the "Start Scan and Reindex Process" and after it is finished click the "Start Optimization Process". After it is finished download files from the "testimages" directory and compare them with the ones in the testimages.zip file. Downloaded files should be smaller in size. If it is working delete the "testimages" directory from your Magento root and in extension configuration for the option "Paths" type "pub" for M2 or "media;skin/frontend" for M1. Now you can use the extension.
For sites with many images please be aware of the memory_limit requirement. Our extension is tested with 1000000+ images in the index. To operate an index with 1000000+ images you need to set PHP value memory_limit to 2048M or more.
For sites with up to 500000 images, the minimal required memory_limit value is: 768M
For sites with up to 250000 images, the minimal required memory_limit value is: 512M
The above values are minimal required ones, if you can set them to a higher value then set them higher.
Configuration
Find Image Optimizer "bin" directory. (Can be "app/code/Apptrian/ImageOptimizer/bin" or "vendor/apptrian/image-optimizer/bin".) Set execute permissions on files inside this directory. These permissions are usually 755. (If you already have gifsicle, jpegtran, and optipng installed on your server use "Utility Exact Path" fields to point extension to your installed versions of these utilities. If utilities are added to the system path then in "Utility Exact Path" fields type only the name of the utility.)
For sites with many images please be aware of the memory_limit requirement. Our extension is tested with 1000000+ images in the index. To operate an index with 1000000+ images you need to set PHP value memory_limit to 2048M or more. You should not worry about this for sites with up to 500000 images because Magento 2 default value for memory_limit is 768M (you can see this in a .htaccess file in your Magento root and this is also where you change memory_limit if needed).
Testing
Please test the extension before you use it!
Download testimages.zip file (inside are test images that are not optimized). Unpack the testimages.zip file into your Magento "pub" directory. Then in our extension configuration for the option "Paths" remove everything and type "pub/testimages". Click the "Start Scan and Reindex Process" button and after it is finished click the "Start Optimization Process" button. After it is finished download files from the "pub/testimages" directory and compare them with the ones in the testimages.zip file. Downloaded files should be smaller in size. (It does not matter how much smaller just needs to be different file size. These are just the test images.) If it is working delete the "testimages" directory from your Magento "pub" directory and in extension configuration for the option "Paths" type "pub". Now you can use the extension.
Be aware that some third-party optimization utilities like optipng might change image file permissions to 664 or 666 after optimization. This is not always desirable so to make sure all optimized images have the right permissions after optimization use the "Force File Permissions" option in our extension config and type permissions you want. Example: 0644 (These permissions might not be good for your server so the best way to know is to look what are your images permissions before you start optimization.)
Be aware that included versions of binary utilities gifsicle, jpegtran, and optipng might not work on every server. If the file size of test images (in bytes) does not change after optimization this means that a particular utility is not compatible with your server. In that case, you need to install a version of the utility specifically created for your server OS.
gifsicle
If you are on Debian/Ubuntu:
sudo apt-get install gifsicle
If you are on Fedora/Centos/RedHat:
sudo yum -y install gifsicle
jpegtran
If you are on Debian/Ubuntu:
sudo apt-get install libjpeg-progs
If you are on Fedora/Centos/RedHat:
sudo yum install libjpeg-turbo-utils
optipng
If you are on Debian/Ubuntu:
sudo apt-get update
sudo apt-get install optipng
If you are on Fedora/Centos/RedHat:
sudo yum install optipng
After utility or utilities are installed, use "GIF Utility Exact Path", "JPG Utility Exact Path", and "PNG Utility Exact Path" and type full path where these are installed on your server or just binary utility name "gifsicle", "jpegtran", "optipng" (without quotes). (Properly installed binary utilities are usually added to the system path so you do not need to type full path for these options.)
Installing the above-mentioned utilities would probably require root access. Because of this, you will probably need to contact your server support. Some shared hosting services do not allow the installation of any binary utility. In that case, you will not be able to use our extension.
Installation of binary utilities on your server is not covered by our installation service nor support service.
If you do not know how to install and/or test the extension or you wish a professional to do it for you, we offer an additional Installation service (that includes testing) for a small fee.
If you want to configure it differently log to your Magento Admin and go to
Stores > Configuration > Apptrian Extensions > Image Optimizer
All options are self-explanatory and have tooltips for additional information.
After changing options make sure you refresh your Magento cache.
If you are an advanced user or web developer you will be pleased to know that extension is fully configurable. You can change optimization options even swap utilities used for optimization with the ones you like. The only requirement is that they are command line utilities. By default, our extension is using optimization utilities recommended by Google PageSpeed Insights. These are gifsicle, jpegtran, and optipng. For example, you could change utility for JPG optimization, and instead of jpegtran use jpegoptim. To do this in extension configuration change "JPG Utility" option to "jpegoptim" and for "JPG Utility Options" type "--strip-all %filepath%". If jpegoptim is installed on your server then for "JPG Utility Exact Path" type "jpegoptim".
This extension is FREE, however, support is NOT
Please understand that we get more than a few emails almost every day asking for support. In most cases, problems are lack of basic Magento knowledge and not reading Installation Instructions. Due to our other projects, we do not have time to answer all of them. Because of this, we cannot provide free support for our free extensions. However, we offer very affordable support options for this extension on our site.
FAQ (For Magento v2)
Q: After upgrading from an older version of Image Optimizer to v2.1.0 (or newer) my old index data is gone and Progress Bar is reset?
A: Image Optimizer v2.1.0 and newer save index data to a file instead of a database. If you are upgrading from any previous version of Image Optimizer prior to v2.1.0 you will lose old index data. Previously optimized images will still be optimized but you will need to re-index and re-optimize all images again. Optimizing images twice or multiple times will not change the quality of images. Image optimization utilities sense if images are optimized and just re-save images without changing them.
To upgrade to new version delete all files from:
app/code/Apptrian/ImageOptimizer
then copy new extension files and issue following commands:
php bin/magento setup:upgrade
php bin/magento cache:flush
then delete all files from:
var/generation/Apptrian/ImageOptimizer
directory.
Q: Image Optimizer does not work for me, is there anything I can do?
A: Maybe. First, follow Testing Instructions. The second step is to check permissions on files inside the Image Optimizer "bin" directory. (Can be "app/code/Apptrian/ImageOptimizer/bin" or "vendor/apptrian/image-optimizer/bin".) The third is to try the "64-bit Utilities" option. The fourth use "Utility Exact Path" options but before you do gifsicle, jpegtran, and optipng must be installed on your server (Contact your server support and ask them to install these for you and to send you the full path where these are installed. Some hosting companies will do this other will not). If gifsicle, jpegtran, and optipng are added to the system path you can just type the name of the binary, not a full path. (Some servers usually have jpegtran installed. The minimal version required for Image Optimizer to work is v8d but the latest version is preferable.)
Q: Why after clicking the "Start Optimization Process" button, none of the images are optimized?
A: Utility binaries located in "app/code/Apptrian/ImageOptimizer/bin" or "vendor/apptrian/image-optimizer/bin" must be executable which means you have to set right permissions on files inside this directory.
Q: After clicking the "Start Optimization Process" button, the error message appears "Optimization failed because PHP exec() function is disabled."?
A: This means your server PHP is configured in such a way that the PHP exec() function is disabled. Contact your hosting company and ask them to allow exec() function. This usually happens on shared hosting accounts and hosting companies keep this function disabled until you ask them to enable it. This function is needed in order for image optimization utilities to be executed. If you cannot execute optimization utilities you cannot optimize images.
Q: Why do Google PageSpeed Insights report my images are not optimized despite I optimized them properly and can see the difference in file size (in bytes)?
A: Our extension only optimizes images on your site, it will not change the format nor resolution of your images. This brings us to the best practices regarding images and the web. You must prepare your images from the start if you want to pass the Google PageSpeed Insights test. This means choosing the right format and resolution for every image.
Image Formats:
GIF is used for images that have very few colors (small web design elements). It is also used for simple animations if it is animated GIF (banners).
JPG is used for images with many colors (photos, product images, and some other design elements).
PNG is used for images where accurate transparency is needed (usually used for design elements, small element backgrounds/css sprites).
Resolution is best explained via an example. Let's say you have an image on your site that is 2000x2000px. However, on your page, it is resized via CSS to 1000x1000px. This means your image is much bigger than it needs to be. If you check your page containing this image via Google PageSpeed Insights it will tell you something like this:
Compressing and resizing http://www.example.com/pub/media/wysiwyg/image.jpg could save 110.1KiB (79% reduction).
You need to download image.jpg then resize it to 1000x1000px with the image editing program of your choice and upload it back to the original location on the server. Then use our extension to optimize it. Only if you did everything correctly you will pass the Google PageSpeed Insights test.
Q: Progress bar is stuck?
A: This happens when in one batch of images there are many very large ones and due to memory and time limits for script execution optimization is aborted. To overcome this, lower the "Batch Size" option to 10. In some cases of very large images and certain server configurations, you will need to set "Batch Size" to 1. After you optimize these large images you can set "Batch Size" back to the default value of 50.
Q: Why are not all images optimized?
A: Only images that are on your server can be optimized. Also sometimes Google PageSpeed Insights will report .gif images with transparency not optimized despite the fact they are. For images that have transparency use .png files. There is also an edge case when you use one format while you would get a much smaller file using another. (Read one of the above FAQs for more information on how to choose the appropriate image format.)
FAQ (For Magento v1)
Q: After upgrading from an older version of Image Optimizer to v2.1.0 (or newer) my old index data is gone and Progress Bar is reset?
A: Image Optimizer v2.1.0 and newer save index data to a file instead of a database. If you are upgrading from any previous version of Image Optimizer prior to v2.1.0 you will lose old index data. Previously optimized images will still be optimized but you will need to re-index and re-optimize all images again. Optimizing images twice or multiple times will not change the quality of images. Image optimization utilities sense if images are optimized and just re-save images without changing them.
Q: After upgrading from an older version of Image Optimizer to 2.2.0 and newer, optimization does not work anymore.
A: If you are upgrading from any previous version of Image Optimizer prior to v2.2.0 after installation/upgrade you need to go to extension configuration and for option "Utilities Path" instead of "lib/apptrian/imageoptimizer" type "lib/Apptrian/ImageOptimizer" then save the changes and refresh your Magento cache. Also set execute permissions on files inside lib/Apptrian/ImageOptimizer directory.
Q: Image Optimizer does not work for me, is there anything I can do?
A: Maybe. First, follow Testing Instructions. The second is to check permissions on files inside lib/Apptrian/ImageOptimizer. The third is to try the "64-bit Utilities" option. The fourth use "Utility Exact Path" options but before you do gifsicle, jpegtran, and optipng must be installed on your server (Contact your server support and ask them to install these for you and to send you the full path where these are installed. Some hosting companies will do this other will not). If gifsicle, jpegtran, and optipng are added to the system path you can just type the name of the binary, not a full path. (Some servers usually have jpegtran installed. The minimal version required for Image Optimizer to work is v8d but the latest version is preferable.)
Q: Why after clicking the "Start Optimization Process" button, none of the images are optimized?
A: Utility binaries located in lib/Apptrian/ImageOptimizer must be executable which means you have to set the right permissions on files inside this directory.
Q: After clicking the "Start Optimization Process" button, the error message appears "Optimization failed because PHP exec() function is disabled."?
A: This means your server PHP is configured in such a way that the PHP exec() function is disabled. Contact your hosting company and ask them to allow exec() function. This usually happens on shared hosting accounts and hosting companies keep this function disabled until you ask them to enable it. This function is needed in order for image optimization utilities to be executed. If you cannot execute optimization utilities you cannot optimize images.
Q: Why do Google PageSpeed Insights report my images are not optimized despite I optimized them properly and can see the difference in file size (in bytes)?
A: Our extension only optimizes images on your site, it will not change the format nor resolution of your images. This brings us to the best practices regarding images and the web. You must prepare your images from the start if you want to pass the Google PageSpeed Insights test. This means choosing the right format and resolution for every image.
Image Formats:
GIF is used for images that have very few colors (small web design elements). It is also used for simple animations if it is animated GIF (banners).
JPG is used for images with many colors (photos, product images, and some other design elements).
PNG is used for images where accurate transparency is needed (usually used for design elements, small element backgrounds/css sprites).
Resolution is best explained via an example. Let's say you have an image on your site that is 2000x2000px. However, on your page, it is resized via CSS to 1000x1000px. If you check your page containing this image via Google PageSpeed Insights it will tell you something like this:
Compressing and resizing http://www.example.com/media/wysiwyg/image.jpg could save 110.1KiB (79% reduction).
You need to download image.jpg then resize it to 1000x1000px with the image editing program of your choice and upload it back to the original location on the server. Then use our extension to optimize it. Only if you did everything correctly you will pass the Google PageSpeed Insights test.
Q: Progress bar is stuck?
A: This happens when in one batch of images there are many very large ones and due to memory and time limits for script execution optimization is aborted. To overcome this, lower the "Batch Size" option to 10. In some cases of very large images and certain server configurations, you will need to set "Batch Size" to 1. After you optimize these large images you can set "Batch Size" back to the default value of 50.
Q: Why are not all images optimized?
A: Only images that are on your server can be optimized. Also sometimes Google PageSpeed Insights will report .gif images with transparency not optimized despite the fact they are. For images that have transparency use .png files. There is also an edge case when you use one format while you would get a much smaller file using another. (Read one of the above FAQs for more info on how to choose the appropriate image format.)
A Word From the Author
Thank you very much for your interest in the Image Optimizer extension. You can rest assured that by choosing this extension you are getting a high-quality product despite the fact it is free. The same professional approach, dedication, and care are invested in this product as if it is paid one. If you find this product useful and want to say "thanks" you can do that by rating it and writing a short review about it on Magento Marketplace. Also, you can like, share and follow us on Facebook, Pinterest, and Twitter.
If you have any questions about extension or Magento in general feel free to contact us.