Closed LukasDeco closed 1 year ago
You need to decode the PNG / JPEG, then resize, then pass it to from_rgba. To do the decoding step you probably want to use the main image crate
Thank you @fintelia! Can I use gif crate to decode it? Or you are saying to use image crate to decode it?
The gif
crate can only decode GIFs. If you want to decode a PNG or JPEG, you'll need to use image
(which internally calls into dedicated crates for each format: png
, jpeg_decoder
, etc.)
Thanks @fintelia! I was able to make it work using image::load_from_memory
and then I used the imageops::resize
crate function to resize it and convert it to an ImageBuffer. Then using the ImageBuffer I can pass that into Frame::from_rgba
if I call into_raw()
on each buffer as I pass it to the frame. and it works like a charm! Thanks for pointing me to the image
crate!
I have some code where I am trying to dynamically generate a gif from various urls. The urls could point to JPGs or PNGs.
Here's my code so far:
And this is the function download_images:
But here's the error I encounter on the
Frame::from_rgba
call:Is there some kind of conversion I need to do on the image before I call Frame::from_rgba? I guess maybe resize the image, but is that all? I'm a newb to Rust so thanks in advance.