I have an image file of webP format. How can I check if it is animated webP or a static image programmatically?
2 Answers
Since you added fresco tag to the question, you could use the following utility:
ImageFormatChecker.getImageFormat_WrapIOException(encodedImage.getInputStream()) should return ImageFormat.WEBP_ANIMATED
Comments
Here are some methods to get formats. Good thing is it identifies animation in webp. (mimeType and extention are same for animated and static type of webp, png, avif images)
InputStream is = ... ;
ImageFormat format = ImageFormatChecker.getImageFormat(is);
or
String uri = ... ;
ImageFormat format = ImageFormatChecker.getImageFormat(uri);
or
InputStream is = ... ;
ImageFormat format = ImageFormatChecker.getImageFormat_WrapIOException(is);
Used Fresco version : 3.1.3.