Skip to content

Commit 757faee

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Add support for reading GIFs without colormap
2 parents fba0b18 + 38365a4 commit 757faee

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

ext/gd/libgd/gd_gif_in.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
244244
BitSet(buf[8], INTERLACE), &ZeroDataBlock);
245245
} else {
246246
if (!haveGlobalColormap) {
247-
gdImageDestroy(im);
248-
return 0;
247+
// Still a valid gif, apply simple default palette as per spec
248+
ColorMap[CM_RED][1] = 0xff;
249+
ColorMap[CM_GREEN][1] = 0xff;
250+
ColorMap[CM_BLUE][1] = 0xff;
249251
}
250252
ReadImage(im, fd, width, height,
251253
ColorMap,

ext/gd/tests/gif_nocolormaps.gif

37 Bytes
Loading

ext/gd/tests/gif_nocolormaps.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
A GIF without any Global or Local color tables is still decoded
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
$im = imagecreatefromgif(__DIR__ . "/gif_nocolormaps.gif");
8+
var_dump($im instanceof GdImage);
9+
?>
10+
--EXPECT--
11+
bool(true)

0 commit comments

Comments
 (0)