Bug #12780 Updated: ImageCopyResampled ignores srcX and srcY parameters
| From: | sander@php.net | Date: | Fri, 31 Aug 2001 10:42:43 +0000 |
| Subject: | Bug #12780 Updated: ImageCopyResampled ignores srcX and srcY parameters | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-64786@lists.php.net to get a copy of this message | ||
ID: 12780
Updated by: sander
Reported By: barnabas@kendall.net
Status: Open
Bug Type: GD related
Operating System: Windows 2000
PHP Version: 4.0.6
New Comment:
[User input: vwallen@antlab.net]
I have experienced an issue identical to bug #12780, on a
Linux machine running RedHat 7.1, Apache 1.3.20, PHP
4.0.6, and GD 2.0.1. The original bug was running under
Win2000.
Previous Comments:
------------------------------------------------------------------------
[2001-08-15 22:31:16] barnabas@kendall.net
The Source X and Y parameters are ignored by the function ImageCopyResampled. This may be a bug with
the GD 2.0.1 library itself, since an examination of gd.c lines 1960-2085 reveal no significant
reference to these parameters. My e-mail to the developers is getting bounced, so I turn to you. I
used the setup program for Windows to install PHP 4.0.6 on a fresh Windows 2000 machine, but I
believe the problem is platform independant.
Here's how to reproduce the bug:
1: Create a 200 x 200 JPEG image named "grid.jpg". Divide it into four colored sqares of
equal size, just for the demonstration.
2: Create an HTML page with the following content:
<p>
<img src="imgTest.php?src_w=100&src_h=100" alt="(src_w=100,
src_h=100)"><br>
<img src="imgTest.php?src_w=100&src_h=100&src_x=100" alt="(src_w=100,
src_h=100, src_x=100)"><br>
<img src="imgTest.php?src_w=100&src_h=100&src_y=100" alt="(src_w=100,
src_h=100, src_y=100)"><br>
<img src="imgTest.php?src_w=100&src_h=100&src_x=100&src_y=100"
alt="(src_w=100, src_h=100, src_x=100, src_y=100)"><br>
</p>
<p>
<img src="imgTest.php?mode=sample&src_w=100&src_h=100" alt="(src_w=100,
src_h=100)"><br>
<img src="imgTest.php?mode=sample&src_w=100&src_h=100&src_x=100"
alt="(src_w=100, src_h=100, src_x=100)"><br>
<img src="imgTest.php?mode=sample&src_w=100&src_h=100&src_y=100"
alt="(src_w=100, src_h=100, src_y=100)"><br>
<img
src="imgTest.php?mode=sample&src_w=100&src_h=100&src_x=100&src_y=100"
alt="(src_w=100, src_h=100, src_x=100, src_y=100)"><br>
</p>
3: Create a PHP page named "imgTest.php" with the following content:
<?php
// test of the GD functions...
$src_img = ImageCreateFromJPEG("./grid.jpg");
if (empty($dest_x)) $dest_x = 0;
if (empty($dest_y)) $dest_y = 0;
if (empty($dest_w)) $dest_w = 100;
if (empty($dest_h)) $dest_h = 100;
if (empty($src_x)) $src_x = 0;
if (empty($src_y)) $src_y = 0;
if (empty($src_w)) $src_w = ImageSX($src_img);
if (empty($src_h)) $src_h = ImageSY($src_img);
$dst_img = ImageCreateTrueColor($dest_w, $dest_h);
if ($mode == "sample") {
ImageCopyResampled( $dst_img, $src_img, $dest_x, $dest_y, $src_x, $src_y, $dest_w, $dest_h, $src_w,
$src_h);
} else {
ImageCopyResized( $dst_img, $src_img, $dest_x, $dest_y, $src_x, $src_y, $dest_w, $dest_h, $src_w,
$src_h);
}
header("Content-type: image/JPEG");
ImageJPEG($dst_img);
ImageDestroy($dst_img);
ImageDestroy($src_img);
?>
The result is that the bottom group of squares will all be from the upper left corner, while the top
group of squares will be separate corners. This shows that the functions are not interchangable.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12780&edit=1