From:             [EMAIL PROTECTED]
Operating system: Windows 2000
PHP version:      4.0.6
PHP Bug Type:     GD related
Bug description:  ImageCopyResampled ignores srcX and srcY parameters

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 bug report at: http://bugs.php.net/?id=12780&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to