fix(images): pick the decoder from the bytes, not the extension
`image::open` chooses the decoder by extension, so a PNG saved as .jpg (Android screenshots, chat exports) failed thumbnails, previews, perceptual hashes, insights and face crops with "Illegal start bytes: 8950". New `file_types::open_image` sniffs the header and falls back to the extension when it's unknown; every decode site uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a605ccd6f8
commit
9222d3e3ae
5 files changed
+29
-6
No files matched your search
+2
-2
@@ -104,7 +104,7 @@ pub fn generate_image_thumbnail(src: &Path, thumb_path: &Path) -> std::io::Resul
|
||||
return generate_image_thumbnail_ffmpeg(src, thumb_path, orientation);
|
||||
}
|
||||
|
||||
let img = image::open(src).map_err(|e| {
|
||||
let img = file_types::open_image(src).map_err(|e| {
|
||||
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("{:?}: {}", src, e))
|
||||
})?;
|
||||
let img = exif::apply_orientation(img, orientation);
|
||||
@@ -148,7 +148,7 @@ pub fn generate_preview(src: &Path, dest: &Path, max_dim: u32) -> std::io::Resul
|
||||
return generate_preview_ffmpeg(src, dest, orientation, max_dim);
|
||||
}
|
||||
|
||||
let img = image::open(src).map_err(|e| {
|
||||
let img = file_types::open_image(src).map_err(|e| {
|
||||
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("{:?}: {}", src, e))
|
||||
})?;
|
||||
let img = exif::apply_orientation(img, orientation);
|
||||
|
||||
Reference in new issue
Block a user