mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 10:41:30 +00:00
LibGfx/PNG: Read metadata from the eXIf chunk
The test image comes from this WPT test: http://wpt.live/png/exif-chunk.html
This commit is contained in:
parent
f28bb90d9b
commit
09f4032eeb
Notes:
sideshowbarker
2024-07-16 20:08:14 +09:00
Author: https://github.com/LucasChollet
Commit: 09f4032eeb
Pull-request: https://github.com/SerenityOS/serenity/pull/24429
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/nico ✅
4 changed files with 33 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <LibGfx/ImageFormats/QMArithmeticDecoder.h>
|
||||
#include <LibGfx/ImageFormats/TGALoader.h>
|
||||
#include <LibGfx/ImageFormats/TIFFLoader.h>
|
||||
#include <LibGfx/ImageFormats/TIFFMetadata.h>
|
||||
#include <LibGfx/ImageFormats/TinyVGLoader.h>
|
||||
#include <LibGfx/ImageFormats/WebPLoader.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
@ -768,6 +769,18 @@ TEST_CASE(test_png)
|
|||
TRY_OR_FAIL(expect_single_frame(*plugin_decoder));
|
||||
}
|
||||
|
||||
TEST_CASE(test_exif)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("png/exif.png"sv)));
|
||||
EXPECT(Gfx::PNGImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::PNGImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 100, 200 }));
|
||||
EXPECT(plugin_decoder->metadata().has_value());
|
||||
auto const& exif_metadata = static_cast<Gfx::ExifMetadata const&>(plugin_decoder->metadata().value());
|
||||
EXPECT_EQ(*exif_metadata.orientation(), Gfx::TIFF::Orientation::Rotate90Clockwise);
|
||||
}
|
||||
|
||||
TEST_CASE(test_png_malformed_frame)
|
||||
{
|
||||
Array test_inputs = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue