[Piston Image crate] Image format conversion?


#1

I currently have an application intended to work with image data using RGB pixel formats. However, I need to allow it to take images of all encodings. My first idea was to convert the image to RGB format before processing, like so:

pub fn process_generic<P,C>(im: image::ImageBuffer<P,C>)
   where P: image::Pixel + 'static,
         P::Subpixel: 'static,
         C: ops::Deref<Target = [P::Subpixel]>
{
    let result:image::ImageBuffer<image::Rgb<u8>, Vec<u8>> = im.convert();
    process(result)
}

However, compiling this gives me an error saying that

the trait bound `image::Rgb<u8>: image::color::FromColor<P>` is not satisfied

It then suggests adding the bound, but I can’t (because the module image::color is private). Am I missing something? I was also attempting to go through and convert each pixel manually, but that seems like a worse way to do it.