You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am excited that this library exists, thanks for your work on this!
My system uses DynamicImage for the image processing, but this crate uses an alternate format for images it seems. It would be great if we can update the documentation to show how to bridge this gap. I have spent time trying to work out the best way to do it but my limited understanding of the underlying image data formats makes it difficult.
I've spent some time trying to work out how to convert from the imageDynamicImage type into avif, and it is not 100% clear to me how it would be done. I have tried a few different ways, the following compiles, but returns img convert failed. How do we get the data out of a DynamicImage so we can pass it to this library?
Assuming this is how an image was opened, or created:
let file = PathBuf::from(src);
let ext = file.extension();
if ext.is_none() {
return Err(format!("source file must have file extension"));
}
let mut img = image::open(src).unwrap();
This is what I am trying to do, which doesn't work:
use rgb::ComponentSlice;
use rgb::FromSlice;
use std::io::Write;
let pr = match img.as_rgba8() {
None => {
// Fails here
return Err(format!("img convert failed"));
}
Some(pr) => pr,
};
let pixels_rgba = pr.as_rgba();
let (width, height) = img.dimensions();
let ist = Img::new(pixels_rgba, width as usize, height as usize);
match Encoder::new()
.with_quality(75.)
.with_speed(1)
.encode_rgba(ist)
{
Err(e) => {
return Err(format!("save image failed. {:?}", e));
}
Ok(res) => {
fi.write_all(res.avif_file.as_slice());
}
}
The text was updated successfully, but these errors were encountered:
I am excited that this library exists, thanks for your work on this!
My system uses DynamicImage for the image processing, but this crate uses an alternate format for images it seems. It would be great if we can update the documentation to show how to bridge this gap. I have spent time trying to work out the best way to do it but my limited understanding of the underlying image data formats makes it difficult.
I've spent some time trying to work out how to convert from the
image
DynamicImage
type into avif, and it is not 100% clear to me how it would be done. I have tried a few different ways, the following compiles, but returnsimg convert failed
. How do we get the data out of aDynamicImage
so we can pass it to this library?Assuming this is how an image was opened, or created:
This is what I am trying to do, which doesn't work:
The text was updated successfully, but these errors were encountered: