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

Format webp rotate image but not for png or jpg #381

Open
4 tasks done
bjarnef opened this issue Mar 5, 2025 · 6 comments
Open
4 tasks done

Format webp rotate image but not for png or jpg #381

bjarnef opened this issue Mar 5, 2025 · 6 comments

Comments

@bjarnef
Copy link

bjarnef commented Mar 5, 2025

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.1.6

Other ImageSharp packages and versions

ImageSharp.Web 3.1.3

Environment (Operating system, version and so on)

Windows 10

.NET Framework version

8.0.113

Description

We noticed in Umbraco 13.7.0 an image uploaded shown correct at thumbnail e.g. ?rmode=max&width=500

Viewing the EXIF meta data via e.g. https://jimpl.com/ I see the following:
Orientation: Rotate 90 CW

Not sure why the rotation is different depending on format though.

The image seems also to be rotated correct using these querystrings:

?quality=80&width=500
?format=jpg&quality=80&width=500
?format=png&quality=80&width=500

Image

but using WebP the image is rotated:

?format=webp&quality=80&width=500

Image

Steps to Reproduce

Use the example image below and test with ?format=webp in querystring.

Images

I have attached the original image used in the example: test.zip

@JimBobSquarePants JimBobSquarePants transferred this issue from SixLabors/ImageSharp Mar 5, 2025
@JimBobSquarePants
Copy link
Member

I moved this to the right repo for you.

See #375 Browsers do not respect these values for WEBP so there’s nothing we can do.

@bjarnef
Copy link
Author

bjarnef commented Mar 5, 2025

Thanks :)

Anyway update to image to workaround this? Because most other images in portrait format is rotated correct.
E.g. this: ai-butterfly.zip

/media/ckdpih5n/ai-og-sommerfugle-2.jpg?format=webp&quality=80

However I don't see the `Orientation EXIF meta data on this image.

@JimBobSquarePants
Copy link
Member

See #375 (comment)

@bjarnef
Copy link
Author

bjarnef commented Mar 5, 2025

Okay, was more looking for a manual solution to adjust image.

I could remove the Orientation EXIF data via https://www.thexifer.net/ ... in that case the image show on Windows is rotated as the WebP example.

We could probably just edit the image and save it as a new image.

Or I could ask ChatGPT to remove it.

Image

@JimBobSquarePants
Copy link
Member

I don’t think you understand what I’m saying. Or maybe I don’t understand what you are asking for. Your image has metadata that says it should be displayed rotated by 90 degrees. The browser is ignoring those instructions because it doesn’t support parsing EXIF rotation for WEBP.

You cannot do anything to make the browser respect those instructions while keeping the format as WEBP.

Removing the instructions will leave your image displayed with the wrong orientation as you currently have.

The only valid workaround would be to create a clone of the image swapping the height and width and remapping the pixel data to the new image saving it again as WEBP with the EXIF instruction removed which is exactly what I suggested with the processor. By using a processor you future proof yourself against future instances.

There’s no magic solution to this.

@bjarnef
Copy link
Author

bjarnef commented Mar 5, 2025

I do understand the issue and the limitation in the browser.

We could handle this as you suggest via code, but since it works correct for this image #381 (comment) without EXIF orientation, I am just suggesting it could be handle manual for these few images.

I rarely see this issue in Umbraco projects, and it seems mainly to be an issue when images uploaded where taken from mobile device camera.

So it is something the content editors could handle themselves. The simplest solution it probably just to edit the image in an image editing tool, e.g. Photoshop, save the image as a new image, and upload this instead.

or when EXIF Orientation meta data is removed, the image is sideways. I can them from right-click menu on Window rotate the image.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants