在JAVA中了解gif是否具有动画效果 [英] Understand an gif is animated or not in JAVA

查看:174
本文介绍了在JAVA中了解gif是否具有动画效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gif图像,我希望能够使用JAVA检测gif是否是动画gif。这个问题是关于检测而不是显示gif。

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. This question is about detection rather than displaying the gif.

我看到动画gif的MIME类型与静态gif没有区别。

I see that MIME type of animated gif isn't different of static gif.

我怎么做?

推荐答案

你需要一个ImageReader。如果size为1则不动画,上面的所有内容都是动画的。
检查出来:

You need an ImageReader. if size is 1 its not animated, everything above is animated. 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();
        }  
}

这篇关于在JAVA中了解gif是否具有动画效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆