This module solves the problem where if the image is already in the correct resolution and compression, imagecache processes that image anyway.

In some cases we do need to change the image scales, which imagecache does well. But in many cases the images are already in the correct resolution and the problem is imagecache is still regenerating those images with the results being worse quality and larger file sizes.
The solution: If the file already has the correct dimensions of the current preset, only copy the file into the directory of that imagecache preset instead of allowing imagecache to process the image.

- Creation of the hook imagecache_preprocess_cache that is invoked before the imagecache image is built allowing an implementation of the hook to intercept, validate and process the cache in various ways. Imagecache already validates the image and preset before building the cache and, for example, redirects the user in case of an error or outputs an existing image cache, but it doesn't allow you to add your custom validation, so this hook solves that problem.

- This module validates four preset actions: imagecache_resize, imagecache_crop, imagecache_scale, imagecache_scale_and_crop. In some cases of these actions (depending on their parameters) it's possible to predict the dimensions of the final output of the preset, check if it would be equal to the original image and copy it to the imagecache directory of the corresponding preset. If the preset has a different action other than the ones mentioned, for example, imagecache_sharpen, the file will not be copied and the imagecache process is continued (unless another module implements the hook).

Essentially, the goal is to validate whether the cache of the image is equal to the original image IF the original image has already been processed and redimensioned and doesn't need to go through image cache's process for a specific preset.

Installation
D6 - Make sure you apply this patch https://drupal.org/node/2114181#comment-7975369 to the imagecache module.

Project information

  • Project categories: Media
  • Created by vgardner on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases