In the function "image_gd_crop" in "image.inc" the first two parameters are in the wrong order resulting in a black image.

From the documentation of "imageCopy" (http://php.belnet.be/manual/nl/function.imagecopy.php):

int imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h)

Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

So by doing:

  $im = image_gd_open($source, $info['extension']);
  $res = imageCreateTrueColor($width, $height);
  imageCopy($im, $res, 0, 0, $x, $y, $width, $height);
  $result = image_gd_close($res, $destination, $info['extension']);

you actually copy a part of the new black image ($res) into the original image ($im) instead of the other way around. The end result is that $res stays a black image. The fact that the original image ($im) now has a black part in it was of no importance as $im is discarted afterwards without saving it back to $source.

The same error is present in CVS-HEAD.

Patch attached (for 4-6).

CommentFileSizeAuthor
image.inc_0.patch638 bytesRobrecht Jacques
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dries’s picture

Status: Needs review » Fixed

Committed to HEAD and DRUPAL-4-6. Thanks.

Anonymous’s picture

ken123’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)