the image.imagemagick.inc file that comes with the Image module appears to have (what I think) is a minor bug -- the crop command does not use the viewport setting (!). This means that cropped gifs and other files which do not discard canvas info post-crop will retain their original size (although image information OUTSIDE of the crop will appear blank) rather than having their overall size reduced. My guess is most people are expecting the latter (I was!).

Fortunately, it's a simple fix. on line 97 of the current image.imagecache.inc file, change:

  $filter = ' -crop '. $width .'x'. $height .'+'. $x .'+'. $y;

to

  $filter = ' -crop '. $width .'x'. $height .'+'. $x .'+'. $y.'!';
CommentFileSizeAuthor
#4 image.imagemagick.inc_183688.patch890 bytesdrewish
#3 title.gif5.14 KBragaskar

Comments

drewish’s picture

Version: 5.x-1.5 » 6.x-1.x-dev

found some documentation of what you're describing: http://www.imagemagick.org/script/command-line-options.php#crop
i need to do some testing to make sure that it doesn't adversely change it for other image types.

drewish’s picture

ragaskar, do you have an image i can use to test that the current behavior is incorrect?

ragaskar’s picture

StatusFileSize
new5.14 KB

yep. try scale and cropping the attached to 100x100 ... i believe that any gif that supports transparency will crop incorrectly, but the attached definitely did for me.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new890 bytes

gotcha. tested and confirmed the bug. i noticed that the resize also uses the !

could you test out the attached patch?

ragaskar’s picture

yep, when I get a chance I will update to head and add the patch in. FWIW, that change has been working fine for me over the last week or so, but there is still a small problem that i haven't addressed yet where the background gets cropped to black for transparencies (it looks like it is possible to crop it to transparency, or at least white).

drewish’s picture

the patch should also work for the 1.x-dev release as well... i backported all the imagemagick changes.

drewish’s picture

Status: Needs review » Fixed

committed to DRUPAL-5 DRUPAL-5--2 and HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.