Hi,
I'm new to Rust. I have a method that accepts an image::DynamicImage and I would like to get image::ImageFormat from it. Is it possible?
image::DynamicImage
image::ImageFormat
My requirement is to check the type of image passed into the method - whether it's png, jpeg etc.
Thanks
Nope. The DynamicImage doesn't encode any format information - it is simply a rectangular matrix of pixels.
DynamicImage
If you have to identify an image format, but don't have the direct method from the language, you can look at the image header and determine the type this way. As long as they are not corrupt, every format will have different header.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.