Identifying animated .gifs with Java

B

Ben Phillips

I'm once again tangled in the thickets of Image/ImageIO documentation
unable to get a fairly simple piece of information.

I can display an animated .gif easily enough, simply by implementing
ImageObserver with a JLabel subclass and having it repaint itself
whenever the ImageObserver sees something changed, and then feeding it
an animated .gif through loadResource or similar.

What I can't seem to do is implement any of the following to the obvious
spec:

public static boolean isAnimatedGif (Image image);

public static boolean isAnimatedGif (File file);

public static boolean isAnimatedGid (URL url);

and ImageIO seems to produce a static BufferedImage of just one frame
from the things.

The minimum I need here is some sort of "isAnimatedGif" method
implementation that will work, or a pointer into the right bit of
API/right third-party library to get me going on doing that bit myself.

FWIW, a google search for "java animated gif" turned up several
references to the ImageObserver trick and nothing else of note.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top