Hello.

I've been working on a upgrading a site to imagecache 2.0 beta. The crop function does not seem to work the way it did in 1.0.

I have a preset set up with two actions:
1: Scale 250 pixels wide, No height value
2: Crop 250 pixels wide, 166 pixels high, center x, center y

My source image is 1144 x 772. The scale should bring to 250x169.

In imagecache 2.0, it does produce an image 250x166, however the lower 49 pixels are all black.

Attached is the imagecache 1.0 image and the imagecache 2.0 image.

Comments

jsm174’s picture

I started to debug this and it seems like the "image" that comes out of the scale that gets feed into the crop has the wrong dimensions. I put debug messages into the scale and crop methods and the math is definitely correct.

imagecache_scale_image: image=stdClass Object ( [source] => files/potw/yuengling260lh8.jpg [info] => Array ( [width] => 640 [height] => 241 [extension] => jpg [file_size] => 68431 [mime_type] => image/jpeg ) [toolkit] => imageapi_gd [res] => Resource id #141 ) , data=Array ( [width] => 198 [height] => [upscale] => 0 )

imagecache_crop_image: image=stdClass Object ( [source] => files/potw/yuengling260lh8.jpg [info] => Array ( [width] => 198 [height] => 198 [extension] => jpg [file_size] => 68431 [mime_type] => image/jpeg ) [toolkit] => imageapi_gd [res] => Resource id #144 ) , data=Array ( [width] => 198 [height] => 132 [xoffset] => 0 [yoffset] => 33 )

-- Jason

jsm174’s picture

Since this is my first time through the flow of image cache please bare with me.

I added some more diags.

imageapi_image_scale(): post toolkit call width=198, height=75, image=stdClass Object ( [source] => files/potw/yuengling260lh8.jpg [info] => Array ( [width] => 198 [height] => 198 [extension] => jpg [file_size] => 68431 [mime_type] => image/jpeg ) [toolkit] => imageapi_gd [res]

The image comes back with the incorrect height of 198.

I think the bug is in:

imageapi_gd_image_resize() in imageapi_gd.module:

$image->res = $res;
$image->info['width'] = $width;
$image->info['height'] = $width; <--- Should be $image->info['height'] = $height;

I will submit a patch in the ImageAPI issues queue.

-- Jason

jsm174’s picture

New issue and patch under ImageAPI created:

http://drupal.org/node/239898

dopry’s picture

Status: Active » Closed (fixed)

this was fixed in imageapi.