Test all exif rotation types and fix two of them (#6102)

This commit is contained in:
Laurenz Stampfl 2025-03-27 11:59:32 +01:00 committed by GitHub
parent 1f1c133878
commit 838a46dbb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 10 deletions

2
Cargo.lock generated
View File

@ -2803,7 +2803,7 @@ dependencies = [
[[package]] [[package]]
name = "typst-dev-assets" name = "typst-dev-assets"
version = "0.13.1" version = "0.13.1"
source = "git+https://github.com/typst/typst-dev-assets?rev=9879589#9879589f4b3247b12c5e694d0d7fa86d4d8a198e" source = "git+https://github.com/typst/typst-dev-assets?rev=fddbf8b#fddbf8b99506bc370ac0edcd4959add603a7fc92"
[[package]] [[package]]
name = "typst-docs" name = "typst-docs"

View File

@ -33,7 +33,7 @@ typst-syntax = { path = "crates/typst-syntax", version = "0.13.1" }
typst-timing = { path = "crates/typst-timing", version = "0.13.1" } typst-timing = { path = "crates/typst-timing", version = "0.13.1" }
typst-utils = { path = "crates/typst-utils", version = "0.13.1" } typst-utils = { path = "crates/typst-utils", version = "0.13.1" }
typst-assets = { git = "https://github.com/typst/typst-assets", rev = "ab1295f" } typst-assets = { git = "https://github.com/typst/typst-assets", rev = "ab1295f" }
typst-dev-assets = { git = "https://github.com/typst/typst-dev-assets", rev = "9879589" } typst-dev-assets = { git = "https://github.com/typst/typst-dev-assets", rev = "fddbf8b" }
arrayvec = "0.7.4" arrayvec = "0.7.4"
az = "1.2" az = "1.2"
base64 = "0.22" base64 = "0.22"

View File

@ -325,12 +325,12 @@ fn apply_rotation(image: &mut DynamicImage, rotation: u32) {
ops::flip_horizontal_in_place(image); ops::flip_horizontal_in_place(image);
*image = image.rotate270(); *image = image.rotate270();
} }
6 => *image = image.rotate90(), 6 => *image = image.rotate270(),
7 => { 7 => {
ops::flip_horizontal_in_place(image); ops::flip_horizontal_in_place(image);
*image = image.rotate90(); *image = image.rotate90();
} }
8 => *image = image.rotate270(), 8 => *image = image.rotate90(),
_ => {} _ => {}
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

View File

@ -247,12 +247,6 @@ A #box(image("/assets/images/tiger.jpg", height: 1cm, width: 80%)) B
format: "rgba8", format: "rgba8",
) )
--- issue-870-image-rotation ---
// Ensure that EXIF rotation is applied.
// https://github.com/image-rs/image/issues/1045
// File is from https://magnushoff.com/articles/jpeg-orientation/
#image("/assets/images/f2t.jpg", width: 10pt)
--- issue-measure-image --- --- issue-measure-image ---
// Test that image measurement doesn't turn `inf / some-value` into 0pt. // Test that image measurement doesn't turn `inf / some-value` into 0pt.
#context { #context {
@ -267,3 +261,16 @@ A #box(image("/assets/images/tiger.jpg", height: 1cm, width: 80%)) B
--- issue-3733-dpi-svg --- --- issue-3733-dpi-svg ---
#set page(width: 200pt, height: 200pt, margin: 0pt) #set page(width: 200pt, height: 200pt, margin: 0pt)
#image("/assets/images/relative.svg") #image("/assets/images/relative.svg")
--- image-exif-rotation ---
#let data = read("/assets/images/f2t.jpg", encoding: none)
#let rotations = range(1, 9)
#let rotated(v) = image(data.slice(0, 49) + bytes((v,)) + data.slice(50), width: 10pt)
#set page(width: auto)
#table(
columns: rotations.len(),
..rotations.map(v => raw(str(v), lang: "typc")),
..rotations.map(rotated)
)