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:
Lucas CHOLLET 2024-05-22 22:45:22 -04:00 committed by Sam Atkins
commit 09f4032eeb
Notes: sideshowbarker 2024-07-16 20:08:14 +09:00
4 changed files with 33 additions and 0 deletions

View file

@ -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 = {