Image Optimization

Image optimization is a feature of NitroPack which allows you to optimize your images by removing any extra image data which is not essential for displaying the image. The process relies on external programs like Jpegoptim, MozJpeg, etc.

It provides lossless and lossy modes. If lossless is selected it will make your images as small as possible without interfering with the quality of the image. If using lossy mode, the same optmiziations will be applied, but the visual quality of the image will be also be reduced to a user configurable percentage.

The image optimization panel is split into 2 main sections - Image Optimization (on the left) and Options (on the right).


Image Optimization

This section is used to start/stop image optimization processes and to display the process status information while working. In order to start a new optimzation process click the blue Start new optimization process button. The process will use the configuration from Options section on the right.


  1. Optimize reported images - This button is only visible after you have refreshed the PageSpeed score and only if there are reported cache images that need to be optimized. Clicking it will start a new optimization process which will only go over the reported cache images, saving you a lot of time if you have many cached images. This comes useful while you are testing different values for the options below.

  2. Optimization Method (Local / Remote) - This setting controls whether the optimization process will be hapenning locally on your server or remotely on our servers. Chosing Local is the preferred option, because it is much faster, however this can only work if executing external programs on your server is allowed. The exec() PHP function must be allowed and the PHP user must have appropriate write permissions. If Local is not working for you, feel free to select the Remote option.

  3. Optimization Type (Lossless / Lossy) - Use this setting to select whether you want the optimization to be Lossless (without reducing image quality) or Lossy (reducing the image quality in order to reduce file size)

  4. Lossy Compression Quality (only visible when Lossy optimization type is selected) - Use this field to define the desired image quality. The number here defines the quality of the final images after the optimization. For example if you put 80 here, the final image will have 80% of the quality of the unoptimized image.

    NoteThe compression quality here must not be confused with the JPEG quality defined in the Image cache section.

    Example: If both places have the quality set to 80, when OpenCart creates a cache image it will create it with 80% of of the original quality. Then when you run the image optimizer, the quality will become 80% of the cached image which in turn is 80% of the original. This means that the final image will be 64% of the quality of the original uncached image.

  5. Optimize On-The-Fly (only visible when Local optimization method is selected) - If this is enabled NitroPack will optimize each cached image as soon as it is created. This way you do not need to run the image optimizer manually, but your first-time page load when the cache is being created may be slightly slower.

  6. Optimize directory/file - This field is only used when you start an optimization process manually. It must be a path to a directory or a file in your OpenCart installation. If it is set to a directory, this directory and all of its subdirectories will be scanned for images and each image will be optimized. If you enter a path to a file, only this file will be optimized. The paths you enter here must will be treated relative to your OpenCart's root. If you leave this empty, the default assumed value will be image/cache/.

    ImportantThe optimization process will overwrite the images that it encounters, so if you are going to be optimizing anything outside of the image/cache/ directory, we strongly recommend you to create a backup of the images in that directory, in order to have their original versions. If you do not create a backup there is no way to restore the original images, because this process is irreversible.

  7. Remove Image Cookies (Yes / No) - If set to yes, NitroPack will add 2 new rules in your .htaccess file which will instruct the web server to omit the Cookie headers when serving images. This is useful for saving bandwidth.