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
Fix for orientation issue of JPEG images #1958
Comments
Thank you very much for sharing this code; it works really well. I found there is a little typo, when } else if orientation == 4 {
// filp V
img = DynamicImage::ImageRgba8(imageops::flip_vertical(&img)); I have referenced it to create a simplified version and applied it to Yazi (a terminal file manager with built-in image preview): fn rotate(mut img: DynamicImage, orientation: u8) -> DynamicImage {
let rgba = img.color().has_alpha();
img = match orientation {
2 => DynamicImage::ImageRgba8(imageops::flip_horizontal(&img)),
3 => DynamicImage::ImageRgba8(imageops::rotate180(&img)),
4 => DynamicImage::ImageRgba8(imageops::flip_vertical(&img)),
5 => DynamicImage::ImageRgba8(imageops::flip_horizontal(&imageops::rotate90(&img))),
6 => DynamicImage::ImageRgba8(imageops::rotate90(&img)),
7 => DynamicImage::ImageRgba8(imageops::flip_horizontal(&imageops::rotate270(&img))),
8 => DynamicImage::ImageRgba8(imageops::rotate270(&img)),
_ => img,
};
if !rgba {
img = DynamicImage::ImageRgb8(img.into_rgb8());
}
img
} Just leaving it here in case someone needs :) |
sxyazi
added a commit
to sxyazi/yazi
that referenced
this issue
Feb 3, 2024
thank you, it works... |
UrsMetz
added a commit
to UrsMetz/markdown-photo-minutes-generator
that referenced
this issue
Apr 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe I have resolved the orientation issue. For more information on this topic, you can refer to the following article: https://magnushoff.com/articles/jpeg-orientation/
To recreate the issue, simply rotate a JPEG image on macOS, which will add orientation metadata to the EXIF data of the image.
The problem at hand is as follows :
this function will help you to get the orientation of image
and you can use it like this to get the right orientation at the end
The text was updated successfully, but these errors were encountered: