mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibGfx: Allow decoding of GIFs with empty LZW data
The decoder was requiring GIF files to be at least 32 bytes, but the actual minimum for a valid GIF is only 26 bytes: - 6 bytes for the header - 7 bytes for the Logical Screen Descriptor - 10 bytes for the Image Descriptor - 2 bytes for the LZW minimum code size and block terminator - 1 byte for the GIF trailer This change allows us to load minimal 1x1 GIFs with empty LZW data. They are commonly used on the web as transparent placeholders with minimal file size.
This commit is contained in:
parent
30d4810d70
commit
b3bdb202f8
Notes:
github-actions[bot]
2025-10-02 09:05:55 +00:00
Author: https://github.com/aplefull
Commit: b3bdb202f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6358
Reviewed-by: https://github.com/gmta ✅
3 changed files with 17 additions and 3 deletions
|
|
@ -215,6 +215,17 @@ TEST_CASE(test_gif_without_global_color_table)
|
|||
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::Red);
|
||||
}
|
||||
|
||||
TEST_CASE(test_gif_empty_lzw_data)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("gif/minimal-1x1.gif"sv)));
|
||||
EXPECT(Gfx::GIFImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::GIFImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
EXPECT_EQ(plugin_decoder->frame_count(), 1u);
|
||||
auto frame = TRY_OR_FAIL(plugin_decoder->frame(0));
|
||||
EXPECT_EQ(frame.image->size(), Gfx::IntSize(1, 1));
|
||||
}
|
||||
|
||||
TEST_CASE(test_not_ico)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("png/buggie.png"sv)));
|
||||
|
|
|
|||
BIN
Tests/LibGfx/test-inputs/gif/minimal-1x1.gif
Normal file
BIN
Tests/LibGfx/test-inputs/gif/minimal-1x1.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 B |
Loading…
Add table
Add a link
Reference in a new issue