[英]Understand an gif is animated or not in JAVA
I have a gif image and I would like to be able to detect whether the gif is an animated gif or not using JAVA. 我有一个gif图像,我希望能够使用JAVA检测gif是否是动画gif。 This question is about detection rather than displaying the gif.
这个问题是关于检测而不是显示gif。
I see that MIME type of animated gif isn't different of static gif. 我看到动画gif的MIME类型与静态gif没有区别。
How I can do it? 我怎么能这样做?
You need an ImageReader. 你需要一个ImageReader。 if size is 1 its not animated, everything above is animated.
如果大小为1则不动画,上面的所有内容都是动画的。 Check this out:
看一下这个:
public Snippet() {
File f = new File("test.gif");
ImageReader is = ImageIO.getImageReadersBySuffix("GIF").next();
ImageInputStream iis;
try {
iis = ImageIO.createImageInputStream(f);
is.setInput(iis);
int images= is.getNumImages(true);
} catch (IOException e) {
e.printStackTrace();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.