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

Link to project page: https://drupal.org/sandbox/vgardner/2114143

In some cases we 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.

Comments

PA robot’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://drupal.org/node/2114199

Project 2: https://drupal.org/node/2111837

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

softescu’s picture

Fixed issues from pareview.sh

README.txt is missing, see the guidelines for in-project documentation.
Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
FILE: /var/www/drupal-7-pareview/pareview_temp/imagecache_use_original.module
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 1 WARNING(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
55 | WARNING | Line exceeds 80 characters; contains 84 characters
75 | ERROR | Whitespace found at end of line
--------------------------------------------------------------------------------

softescu’s picture

Status: Needs review » Needs work
vgardner’s picture

Status: Needs work » Needs review

Thanks for the review, the above issues have now been resolved.

auworks’s picture

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

kscheirer’s picture

Issue summary: View changes
Status: Needs review » Needs work
Master Branch
It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

I don't think your logic is quite right in imagecache_use_original_image(). Don't you want to return FALSE if there is any action that's *not* one of the 4 you validate?

Otherwise this seems reasonable enough. You can also adjust imagecache's settings for jpg quality if you're not getting the results you want, but overall I can see the utility here.

----
Top Shelf Modules - Crafted, Curated, Contributed.

vgardner’s picture

Thanks for the review @kscheirer,
Regarding the imagecache_use_original_image() returning FALSE, that's exactly what it's doing. If one of the actions is not found in the current preset that's being checked it will either try to find one in next preset or return FALSE. However, I've found a couple of function naming mistakes and have fixed that.

Regarding the image quality, for most scenarios where images aren't optimized beforehand, imagecache works great. In this case I just want to ignore imagecache in cases where it doesn't really need to, since editors have already optimized images using different tools.

vgardner’s picture

Status: Needs work » Needs review
tallosoft’s picture

Status: Needs review » Needs work

I am not 100% positive of this, but I do not see a 6.x-1.x branch for this project. I haven't submitted a project for d6, so I don;t know if the same rules apply for branch naming, but I think you should really have a consistent branch name that lists the drupal version!

Your project description and readme look great and informative to me.

I reviewed the code, but did not install. I think it looks pretty good, and will be a good tool in the toolbox!

vgardner’s picture

Thanks for the great feedback @tallosoft. I agree and have included the 6.x-1.x branch.

vgardner’s picture

Status: Needs work » Needs review
vgardner’s picture

Issue summary: View changes
gisle’s picture

Status: Needs review » Postponed (maintainer needs more info)
Duplication
No. Unless I am overlooking something fundamental, this sounds like a feature that should live in the existing ImageCache project. Module duplication and fragmentation is a huge problem on drupal.org and we prefer collaboration over competition. Please open an issue in the ImageCache issue queue to discuss what you need. You should also get in contact with the maintainer(s) to offer your help to move the project forward. If you cannot reach the maintainer(s) please follow the abandoned project process.

If that fails for whatever reason please get back to us and set this back to "needs review".

Code long/complex enough for review
No: It does not follow the guidelines for project length and complexity.
Master Branch
No. It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Git Clone Command
No. There is no git clone command in your issue summary.
Automated Review
PAReview reported some issues. However, please note that these are not substantial and fixing all issues is not a requirement for getting through the application process.
PA robot’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

apaderno’s picture