|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-08-31 06:42 UTC] sander@php.net
[2001-10-20 17:36 UTC] barnabas at kendall dot net
[2002-05-13 16:06 UTC] hannes at phpug dot ch
[2002-05-13 16:21 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 07:00:01 2025 UTC |
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.