Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heifsave: set image orientation using irot and imir transformations #4314

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

lovell
Copy link
Member

@lovell lovell commented Dec 8, 2024

There's previously been some confusion around HEIF and orientation so #1681 made the sensible decision to let libheif deal with this on the input side.

More recently, commit strukturag/libheif@4d9f13b has added support for a similar feature to the output side, which this PR takes advantage of.

Originally reported at lovell/sharp#4289, which includes a sample image.

$ vipsheader --field=orientation in.jpg 
8
$ vips copy in.jpg out.avif

Before:

$ heif-info out.avif 
MIME type: image/avif
main brand: avif
compatible brands: avif, mif1, miaf

image: 810x1080 (id=1), primary
  colorspace: YCbCr, 4:2:0
  bit depth: 8
  color profile: rICC
  alpha channel: no 
  depth channel: no
metadata:
  Exif: 5128 bytes
transformations:
  none
region annotations:
  none

After:

$ heif-info out.avif 
MIME type: image/avif
main brand: avif
compatible brands: avif, mif1, miaf

image: 1080x810 (id=1), primary
  colorspace: YCbCr, 4:2:0
  bit depth: 8
  color profile: rICC
  alpha channel: no 
  depth channel: no
metadata:
  Exif: 5128 bytes
transformations:
  angle (ccw): 90
region annotations:
  none

Copy link
Member

@kleisauke kleisauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo a small suggestion.

FWIW, this seems to require at least libheif v1.19.0 to function correctly, as earlier versions produce a 810x1080 image with that sample.

libvips/foreign/heifsave.c Show resolved Hide resolved
@lovell lovell merged commit 33ab2cc into libvips:8.16 Dec 16, 2024
6 checks passed
@lovell lovell deleted the 8.16-heifsave-image-orientation branch December 16, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants