Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "ext/standard/info.h"
#include "php_open_temporary_file.h"
#include "php_memory_streams.h"
#include "zend_attributes.h"
#include "zend_object_handlers.h"

#ifdef HAVE_SYS_WAIT_H
Expand Down
1 change: 1 addition & 0 deletions ext/gd/gd.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ function imagegd2(GdImage $image, ?string $file = null, int $chunk_size = 128, i
/** @param resource|string|null $file */
function imagebmp(GdImage $image, $file = null, bool $compressed = true): bool {}

#[\Deprecated(since: '8.5', message: "as it has no effect since PHP 8.0")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't notice in the RFC, but the consistent wording with the existing functions would be:

Suggested change
#[\Deprecated(since: '8.5', message: "as it has no effect since PHP 8.0")]
#[\Deprecated(since: '8.5', message: "as GdImage objects are freed automatically")]

Copy link
Member Author

@DanielEScherzer DanielEScherzer Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we proposed the wording on the RFC, I'd prefer to start with using that message and then we can tweak it in a separate patch if desired; same for the other patches for the no-op deprecations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay with me (that's why I opted just to comment rather than “Request Changes”).

function imagedestroy(GdImage $image): true {}

function imagecolorallocate(GdImage $image, int $red, int $green, int $blue): int|false {}
Expand Down
12 changes: 10 additions & 2 deletions ext/gd/gd_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions ext/gd/tests/bug19366.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ echo "Alive: Send to browser\n";
//Header("Content-type: image/PNG");
//ImagePNG($ImHandle);

echo "Alive: Free resources\n";
imagedestroy($ImHandle);
echo "Alive: Done\n";
?>
--EXPECT--
Expand All @@ -46,5 +44,4 @@ Alive: Define colors
Alive: Draw
Alive: ImageString
Alive: Send to browser
Alive: Free resources
Alive: Done
2 changes: 0 additions & 2 deletions ext/gd/tests/bug28147.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ imagefilledrectangle($im,0,0,299,299,$w);
imageantialias($im,true);
imageline($im, 299, 299, 0, 299, $red);

imagedestroy($im);

echo "Alive\n";
?>
--EXPECT--
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/tests/bug36697-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ imagecolortransparent($im, $trans_color);
imagefilledrectangle($im, 0,0, 192,36, $trans_color);
$c = imagecolorat($im, 191,35);
imagegif($im, $dest);
imagedestroy($im);
$im = null;
$im = imagecreatefromgif($dest);
$c = imagecolorat($im, 191, 35);
$colors = imagecolorsforindex($im, $c);
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/tests/bug36697.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ imagecolortransparent($im, $trans_color);
imagefilledrectangle($im, 0,0, 192,36, $trans_color);
$c = imagecolorat($im, 191,35);
imagegif($im, $dest);
imagedestroy($im);
$im = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$im = null;
unset($im);

I have a feeling that unset() would capture the intent a little better, but no strong opinion.

$im = imagecreatefromgif($dest);
$c = imagecolorat($im, 191, 35);
$colors = imagecolorsforindex($im, $c);
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/bug38179.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ imagecopy($dst_tc, $src, 0,0, 0,0, imagesx($src), imagesy($src));

$p1 = imagecolorat($dst_tc, 3,3);
printf("%X\n", $p1);

imagedestroy($src); imagedestroy($dst_tc);
?>
--EXPECT--
46FF0000
2 changes: 0 additions & 2 deletions ext/gd/tests/bug42434.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ if (imagecolorat($im, 9, 0) == 0x000000) {
} else {
echo 'Bugged';
}

imagedestroy($im);
?>
--EXPECT--
DONE
2 changes: 0 additions & 2 deletions ext/gd/tests/bug43121.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ $im_tile = ImageCreateFromGif(__DIR__ . "/bug43121.gif" );
ImageSetTile( $im, $im_tile );
ImageFill( $im, 0, 0, IMG_COLOR_TILED );

ImageDestroy( $im );

print "OK";
?>
--EXPECT--
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/bug43828.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ imagefilledarc($im, 49, 49, 99,99, 0 , 360, $color, IMG_ARC_PIE);

include_once __DIR__ . '/func.inc';
test_image_equals_file(__DIR__ . '/bug43828.png', $im);

imagedestroy($im);
?>
--EXPECT--
The images are equal.
1 change: 0 additions & 1 deletion ext/gd/tests/bug45799.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if (!(imagetypes() & IMG_PNG)) {
<?php
$img = imagecreate(500,500);
imagepng($img);
imagedestroy($img);
?>
--EXPECTF--
Warning: imagepng(): gd-png error: no colors in palette%win %s on line %d
2 changes: 0 additions & 2 deletions ext/gd/tests/bug50194.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ if (isset($matches[1]) && $matches[1] > 2000) {
} else {
echo "The images are similar.\n";
}

imagedestroy($im);
?>
--EXPECT--
The images are similar.
1 change: 0 additions & 1 deletion ext/gd/tests/bug61221.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ imageline($img, 0, $imageh / 2, $imagew - 1, $imageh / 2, $redsolid);
imagegammacorrect($img, 1, 1);
$color = imagecolorat($img, 0, 0);
var_dump($color === $blacktransparent);
imagedestroy($img);
?>
--EXPECT--
bool(true)
2 changes: 0 additions & 2 deletions ext/gd/tests/bug65148.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ foreach ($interpolations as $name => $interpolation) {
$t = imagecolorallocatealpha($img, 0, 0, 0, 127);
$imgr = imagerotate($img, -5, $t);
$results[$name] = array('x' => imagesx($imgr), 'y' => imagesy($imgr));
imagedestroy($imgr);
}

imagedestroy($img);
print_r($results);
?>
--EXPECT--
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/bug67325.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ for ($i = 0; $i < 256; $i++) {
}
}
var_dump($white);

imagedestroy($im);
?>
--EXPECT--
int(0)
4 changes: 0 additions & 4 deletions ext/gd/tests/bug67447.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ $red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
var_dump(imagecolorat($cropped, 249, 249) === $red);
imagedestroy($image);
imagedestroy($cropped);

// palette
$image = imagecreate(500, 500);
Expand All @@ -20,8 +18,6 @@ $red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
var_dump(imagecolorsforindex($cropped, imagecolorat($cropped, 249, 249)));
imagedestroy($image);
imagedestroy($cropped);
?>
--EXPECT--
bool(true)
Expand Down
1 change: 0 additions & 1 deletion ext/gd/tests/bug69024.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ gd
<?php
$im = imagecreate(256, 256);
imagescale($im, 32, 32, IMG_BICUBIC);
imagedestroy($im);
echo "done\n";
?>
--EXPECT--
Expand Down
1 change: 0 additions & 1 deletion ext/gd/tests/bug70102.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ $white = imagecolorallocate($im, 255, 255, 255);
var_dump($white & 0xffffff);
imagefilledrectangle($im, 0, 0, 7, 7, $white);
imagewebp($im, $filename);
imagedestroy($im);

$im = imagecreatefromwebp($filename);
$color = imagecolorat($im, 4, 4);
Expand Down
3 changes: 0 additions & 3 deletions ext/gd/tests/bug72339.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ fclose($fh);

$im = imagecreatefromgd2($fname);

if ($im) {
imagedestroy($im);
}
unlink($fname);

?>
Expand Down
1 change: 0 additions & 1 deletion ext/gd/tests/bug72709.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ catch (\Error $ex) {
}

imagesetpixel($im, 0, 0, IMG_COLOR_STYLED);
imagedestroy($im);
?>
====DONE====
--EXPECT--
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/bug77198_auto.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ for ($y = 0; $y < 8; $y++) {
if ($color !== 0x000000) {
printf("Pixel at %d, %d: unexpected color (%d)\n", $x, $y, $color);
}
imagedestroy($cropped);
}
imagedestroy($orig);
}
}

Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/bug77198_threshold.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ for ($y = 0; $y < 8; $y++) {
if ($color !== 0x000000) {
printf("Pixel at %d, %d: unexpected color (%d)\n", $x, $y, $color);
}
imagedestroy($cropped);
}
imagedestroy($orig);
}
}

Expand Down
1 change: 0 additions & 1 deletion ext/gd/tests/colorat.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ echo 'test colorat truecolor: ';
$c = imagecolorat($im, 3,3);
echo $c == 0x0 ? 'ok' : 'failed';
echo "\n";
imagedestroy($im);

$im = imagecreate(6,6);
$c1 = imagecolorallocate($im, 255,255,255);
Expand Down
12 changes: 6 additions & 6 deletions ext/gd/tests/colorclosest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gd
$im = imagecreatetruecolor(5,5);
$c = imagecolorclosest($im, 255,0,255);
printf("%X\n", $c);
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
$c = imagecolorclosest($im, 255,0,255);
Expand All @@ -17,13 +17,13 @@ try {
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
imagecolorallocate($im, 255, 0, 255);
$c = imagecolorclosest($im, 255,0,255);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0);
Expand All @@ -46,7 +46,7 @@ print_r(imagecolorsforindex($im, $c));
$im = imagecreatetruecolor(5,5);
$c = imagecolorclosestalpha($im, 255,0,255,100);
printf("%X\n", $c);
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
$c = imagecolorclosestalpha($im, 255,0,255,100);
Expand All @@ -55,13 +55,13 @@ try {
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
imagecolorallocatealpha($im, 255, 0, 255, 1);
$c = imagecolorclosestalpha($im, 255,0,255,1);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1);
Expand Down
4 changes: 1 addition & 3 deletions ext/gd/tests/colorexact.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $c2 = imagecolorexactalpha($im, 255,0,255, 100);
printf("%X\n", $c);
printf("%X\n", $c2);

imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
$c = imagecolorallocate($im, 255,0,255);
Expand All @@ -26,8 +26,6 @@ echo imagecolorexactalpha($im, 255,200,0,100) . "\n";

// unallocated index
echo imagecolorexact($im, 12,12,12) . "\n";

imagedestroy($im);
?>
--EXPECT--
FF00FF
Expand Down
2 changes: 0 additions & 2 deletions ext/gd/tests/colormatch.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ try {
}

echo "ok\n";

imagedestroy($im);
?>
--EXPECT--
imagecolormatch(): Argument #2 ($image2) must have at least one color
Expand Down
8 changes: 4 additions & 4 deletions ext/gd/tests/colorresolve.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ gd
$im = imagecreatetruecolor(5,5);
$c = imagecolorresolve($im, 255,0,255);
printf("%X\n", $c);
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
$c = imagecolorresolve($im, 255,0,255);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0);
Expand All @@ -38,12 +38,12 @@ print_r(imagecolorsforindex($im, $c));
$im = imagecreatetruecolor(5,5);
$c = imagecolorresolvealpha($im, 255,0,255, 100);
printf("%X\n", $c);
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
$c = imagecolorresolvealpha($im, 255,0,255,100);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);
$im = null;

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1);
Expand Down
6 changes: 4 additions & 2 deletions ext/gd/tests/copy.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ if ($p1 && $p2 && $p3) {
echo "TC/TC: ok\n";
}

imagedestroy($src_tc); imagedestroy($dst_tc);
$src_tc = null;
$dst_tc = null;


$src_tc = imagecreatetruecolor(5,5);
Expand All @@ -46,7 +47,8 @@ $p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff;
if ($p1 && $p2 && $p3) {
echo "TC/P: ok\n";
}
imagedestroy($src_tc); imagedestroy($dst_tc);
$src_tc = null;
$dst_tc = null;



Expand Down
Loading