PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Images » Image_Transform » Bug #7667

commandline imagick fails with crop and resize

Details

Submitted2006-05-19 00:08 UTC
Fromtroelskn at gmail dot com
StatusWont fix
PackageImage_Transform
PHP VersionIrrelevant
OSwin xp pro
Roadmaps(Not assigned)

Comments

[2006-05-19 00:08 UTC] troelskn at gmail dot com

Description:
------------
I don't have the time to produce a proper testcase to describe the problem, but it appears that when you call resize and crop in the same transformation, imagemagick crops the image, but puts some white "padding" on the part of the image that is "cropped away". this may well be a feature of imagemagick, but it's not the expected behaviour. the gdlib drivers works as expected.

i managed to fix the problem by rewriting the -crop option to two -chop instead :

function crop($height, $width, $x, $y, $options=NULL) {
$x = (int) $x;
$y = (int) $y;
$width = (int) $width;
$height = (int) $height;
$this->command['crop'] = "";
if ($y > 0 || $x > 0) {
$this->command['crop'] .= ' -chop '.$x.'x'.$y.'+0+0';
}
if (($height + $y) < $this->img_y || ($width + $x) < $this->img_x) {
$this->command['crop'] .= ' -chop '.$x.'x'.$y;
if (($width + $x) < $this->img_x) {
$this->command['crop'] .= '+'.$width;
}
if (($height + $y) < $this->img_y) {
$this->command['crop'] .= '+'.$height;
}
}
}