diff --git a/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h b/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h index 36bf7b6c59..381375ba68 100644 --- a/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h +++ b/Libraries/LibGfx/ImageFormats/ExifOrientedBitmap.h @@ -92,7 +92,7 @@ private: case Orientation::FlipVertically: return IntPoint(point.x(), m_height - point.y() - 1); case Orientation::Rotate90ClockwiseThenFlipHorizontally: - return flip_horizontally(rotate_90_clockwise(point)); + return IntPoint(point.y(), point.x()); case Orientation::Rotate90Clockwise: return rotate_90_clockwise(point); case Orientation::FlipHorizontallyThenRotate90Clockwise: diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 84575ccea5..dbfef414f0 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -546,6 +546,22 @@ TEST_CASE(test_exif) EXPECT_EQ(frame.image->get_pixel(190, 10), Gfx::Color(255, 0, 0)); } +TEST_CASE(test_exif_orientation_transpose_non_square) +{ + auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("png/exif-orientation-5.png"sv))); + EXPECT(Gfx::PNGImageDecoderPlugin::sniff(file->bytes())); + auto plugin_decoder = TRY_OR_FAIL(Gfx::PNGImageDecoderPlugin::create(file->bytes())); + + auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 1, 3 })); + EXPECT(plugin_decoder->metadata().has_value()); + auto const& exif_metadata = static_cast(plugin_decoder->metadata().value()); + EXPECT_EQ(*exif_metadata.orientation(), Gfx::TIFF::Orientation::Rotate90ClockwiseThenFlipHorizontally); + + EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color(255, 0, 0)); + EXPECT_EQ(frame.image->get_pixel(0, 1), Gfx::Color(0, 255, 0)); + EXPECT_EQ(frame.image->get_pixel(0, 2), Gfx::Color(0, 0, 255)); +} + TEST_CASE(test_png_malformed_frame) { Array test_inputs = { diff --git a/Tests/LibGfx/test-inputs/png/exif-orientation-5.png b/Tests/LibGfx/test-inputs/png/exif-orientation-5.png new file mode 100644 index 0000000000..b6b7176e64 Binary files /dev/null and b/Tests/LibGfx/test-inputs/png/exif-orientation-5.png differ