Add support for reading GIFs without colormap

Cf. <fc38677e80>.

Closes GH-17364.
This commit is contained in:
Christoph M. Becker 2025-01-05 11:23:15 +01:00
parent 91384e561f
commit 38365a44d0
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
4 changed files with 17 additions and 2 deletions

2
NEWS
View file

@ -22,6 +22,8 @@ PHP NEWS
images). (cmb)
. Ported fix for libgd 223 (gdImageRotateGeneric() does not properly
interpolate). (cmb)
. Added support for reading GIFs without colormap to bundled libgd. (Andrew
Burley, cmb)
- Intl:
. Fixed bug GH-11874 (intl causing segfault in docker images). (nielsdos)

View file

@ -244,8 +244,10 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
BitSet(buf[8], INTERLACE), &ZeroDataBlock);
} else {
if (!haveGlobalColormap) {
gdImageDestroy(im);
return 0;
// Still a valid gif, apply simple default palette as per spec
ColorMap[CM_RED][1] = 0xff;
ColorMap[CM_GREEN][1] = 0xff;
ColorMap[CM_BLUE][1] = 0xff;
}
ReadImage(im, fd, width, height,
ColorMap,

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 B

View file

@ -0,0 +1,11 @@
--TEST--
A GIF without any Global or Local color tables is still decoded
--EXTENSIONS--
gd
--FILE--
<?php
$im = imagecreatefromgif(__DIR__ . "/gif_nocolormaps.gif");
var_dump($im instanceof GdImage);
?>
--EXPECT--
bool(true)