feat: guess format from magic numbers as well

this allows opening files with extensions that don't match the filetype
This commit is contained in:
electria 2026-07-31 09:16:38 -07:00
commit 973703726f
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -7,7 +7,7 @@ use rfd::FileDialog;
pub fn load_image(path: impl AsRef<Path>) -> Result<RgbaImage, String> {
let path = path.as_ref();
let image_reader = match ImageReader::open(path) {
let image_reader = match ImageReader::open(path).and_then(|r| r.with_guessed_format()) {
Ok(r) => r,
Err(e) => {
return Err(format!(