-
Hi, I can't see in docs or examples how to convert an image to another type? I have loaded it: if let Ok(img) = image::load_from_memory_with_format(&data, image_format) {
// Now I would like to convert it to another type, something like:
let converted_img = img.convert(image::ImageFormat::WebP);
} |
Beta Was this translation helpful? Give feedback.
Answered by
fintelia
Feb 2, 2024
Replies: 1 comment 1 reply
-
You want to use the let mut bytes: Vec<u8> = Vec::new();
img.write_to(&mut Cursor::new(&mut bytes), image::ImageOutputFormat::WebP)?; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sekoyo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want to use the
write_to
method: