mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix #79615: Wrong GIF header written in GD GIFEncode
The color resolution is expected in bits 4-6 of the packed fields byte of the logical screen descriptor (byte 10 of the GIF data stream), according to the specification[1], section 18. [1] <https://www.w3.org/Graphics/GIF/spec-gif89a.txt>
This commit is contained in:
parent
85ac5643ff
commit
d4bd6fb491
3 changed files with 24 additions and 1 deletions
3
NEWS
3
NEWS
|
@ -6,6 +6,9 @@ PHP NEWS
|
|||
. Fixed bug #79566 (Private SHM is not private on Windows). (cmb)
|
||||
. Fixed bug #79489 (.user.ini does not inherit). (cmb)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #79615 (Wrong GIF header written in GD GIFEncode). (sageptr, cmb)
|
||||
|
||||
- MySQLnd:
|
||||
. Fixed bug #79596 (MySQL FLOAT truncates to int some locales). (cmb)
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ GIFEncode(gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background
|
|||
/*
|
||||
* OR in the resolution
|
||||
*/
|
||||
B |= (Resolution - 1) << 5;
|
||||
B |= (Resolution - 1) << 4;
|
||||
|
||||
/*
|
||||
* OR in the Bits per Pixel
|
||||
|
|
20
ext/gd/tests/bug79615.phpt
Normal file
20
ext/gd/tests/bug79615.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
Bug #79615 (Wrong GIF header written in GD GIFEncode)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreate(3, 3); // 3x3, 9 colors, 4 bits per pixel
|
||||
for ($x = 0; $x < 3; $x++) {
|
||||
for ($y = 0; $y < 3; $y++) {
|
||||
imagesetpixel($im, $x, $y, imagecolorallocate($im, $x, $y, 0));
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
imagegif($im);
|
||||
echo decbin(ord(ob_get_clean()[0xA]));
|
||||
?>
|
||||
--EXPECT--
|
||||
10110011
|
Loading…
Add table
Add a link
Reference in a new issue