diff --git a/common/src/assets.rs b/common/src/assets.rs index 737810da46..8d7fed412e 100644 --- a/common/src/assets.rs +++ b/common/src/assets.rs @@ -98,8 +98,13 @@ impl Image { pub struct ImageLoader; impl Loader for ImageLoader { - fn load(content: Cow<[u8]>, _: &str) -> Result { - let image = image::load_from_memory(&content)?; + fn load(content: Cow<[u8]>, ext: &str) -> Result { + let format = match ext { + "png" => image::ImageFormat::Png, + "jpg" => image::ImageFormat::Jpeg, + _ => return Err("unknown image format".into()), + }; + let image = image::load_from_memory_with_format(&content, format)?; Ok(Image(Arc::new(image))) } }