#38627 [NEW]: Image resources seem to be reused although destroyed

From: Date: Mon, 28 Aug 2006 14:36:50 +0000
Subject: #38627 [NEW]: Image resources seem to be reused although destroyed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101437@lists.php.net to get a copy of this message
From: toby@php.net Operating system: Gentoo PHP version: 5.2.0RC2 PHP Bug Type: GD related Bug description: Image resources seem to be reused although destroyed Description: ------------ 1. Allocate an image resource $a. 2. Resample (scale) $a to a second resource $b. 3. Destroy $a. 4. Assign $a = $b. 5. Resample (crop) $a to a third resource $c. 6. Destroy $a. 7. Assign $a = $c. For step 5 the initially allocated resource is used instead of the originally resampled one. Reproduce code: --------------- <?php // http://schlitt.info/misc/gd/test_original.jpg $res_1 = imagecreatefromjpeg( "test_original.jpg" ); $res_2 = imagecreatetruecolor( 200, 151 ); // Scale the image to 200x151 $res = imagecopyresampled( $res_2, // dst_img $res_1, // res_img 0, // dst_x 0, // dst_y 0, // src_x 0, // src_y 200, // dst_width 151, // dst_height 150, // src_width 113 // src_height ); // http://schlitt.info/misc/gd/test_scaled.jpg imagejpeg( $res_2, "test_scaled.jpg" ); imagedestroy( $res_1 ); $res_1 = $res_2; $res_3 = imagecreatetruecolor( 100, 100 ); // Crop the image to 100x100 selecting 50x150+50x150 $res = imagecopyresampled( $res_3, // dst_img $res_1, // res_img 0, // dst_x 0, // dst_y 50, // src_x 50, // src_y 100, // dst_width 100, // dst_height 150, // src_width 150 // src_height ); // http://schlitt.info/misc/gd/test_cropped.jpg imagejpeg( $res_3, "test_cropped.jpg" ); imagedestroy( $res_1 ); $res_1 = $res_3; // http://schlitt.info/misc/gd/test_final.jpg imagejpeg( $res_1, "test_final.jpg" ); ?> Expected result: ---------------- test_cropped.jpg should be a cropped version of test_scaled.php Actual result: -------------- test_cropped.jpg is a cropped version of test_original.jpg -- Edit bug report at http://bugs.php.net/?id=38627&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38627&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38627&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38627&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38627&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38627&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38627&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38627&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38627&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38627&r=support Expected behavior: http://bugs.php.net/fix.php?id=38627&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38627&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38627&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38627&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38627&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38627&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38627&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38627&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38627&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38627&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38627&r=mysqlcfg

« previous php.bugs (#101437) next »