fix: use exif oreintation
https://alexwlchan.net/2025/create-thumbnail-is-exif-aware/
This commit is contained in:
parent
53f78d9588
commit
831def32a4
1 changed files with 27 additions and 2 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -5,7 +5,10 @@ use iced::{
|
|||
keyboard::{self, Key, key},
|
||||
theme, widget, window,
|
||||
};
|
||||
use image::{EncodableLayout, ImageReader, RgbaImage, codecs::webp::WebPEncoder, imageops};
|
||||
use image::{
|
||||
DynamicImage, EncodableLayout, ImageDecoder, ImageReader, RgbaImage, codecs::webp::WebPEncoder,
|
||||
imageops,
|
||||
};
|
||||
use rfd::FileDialog;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -124,7 +127,27 @@ impl State {
|
|||
}
|
||||
};
|
||||
|
||||
let decoded_image = match reader.decode() {
|
||||
let mut decoder = match reader.into_decoder() {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
return Some(format!(
|
||||
"failed to create decoder for '{}': {e}",
|
||||
path.as_ref().display()
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let oreintation = match decoder.orientation() {
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
return Some(format!(
|
||||
"failed to get oreintation of '{}': {e}",
|
||||
path.as_ref().display()
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let mut decoded_image = match DynamicImage::from_decoder(decoder) {
|
||||
Ok(i) => i,
|
||||
Err(e) => {
|
||||
return Some(format!(
|
||||
|
|
@ -134,6 +157,8 @@ impl State {
|
|||
}
|
||||
};
|
||||
|
||||
decoded_image.apply_orientation(oreintation);
|
||||
|
||||
self.image = Some(decoded_image.into_rgba8());
|
||||
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue