[drupal-devel] [bug] image.inc: image_gd_crop lists parameters in
wrong order
robrechtj
drupal-devel at drupal.org
Sat Jul 30 19:22:26 UTC 2005
Issue status update for
http://drupal.org/node/27863
Post a follow up:
http://drupal.org/project/comments/add/27863
Project: Drupal
Version: 4.6.0
Component: base system
Category: bug reports
Priority: normal
Assigned to: Anonymous
Reported by: robrechtj
Updated by: robrechtj
Status: patch (code needs review)
Attachment: http://drupal.org/files/issues/image.inc_0.patch (638 bytes)
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:
<?php
$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).
robrechtj
More information about the drupal-devel
mailing list