Hi Yonghui,
You can use the ImageIO framework of JDK1.4 for getting the
no. of frames in the attached gif file.
Use the following code for finding the same.
import javax.imageio.*;
import javax.imageio.stream.*;
import java.util.*;
import java.io.*;
public class ImageCount {
File file = new File("a.gif");
ImageReader reader = null;
ImageInputStream iis = null;
public ImageCount() {
try{
ImageInputStream iis = ImageIO.createImageInputStream(file);
Iterator iter = ImageIO.getImageReaders(iis);
while (iter.hasNext()) {
reader = (ImageReader)iter.next();
break;
}
reader.setInput(iis, false);
int count = reader.getNumImages(true);
System.out.println(count);
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String args[]) {
ImageCount cnt = new ImageCount();
}
}
Note that animated GIF do not specify how many images are
present in the stream. Thus determining the number of images will
require the entire stream to be scanned. Hence i am passing true to
getNumImages() to indicate that the entire stream can be searched
through
for finding out the number of frames.
Please let me know if you have any problem.
Regards,
Praveen
wapcn wrote:
-----------------------------
Hi sir:
Can you tell me how to get a gif file it is how many frame?
Example a a.gif file?
Best regards
---Yonghui
begin:vcard
n:Mohan;Praveen
tel;cell:98401 49793
tel;home:91-44-491 0657
tel;work:91-44-254 1473 / 74 Extn: 314
x-mozilla-html:TRUE
org:SIP Technologies & Exports Ltd;OWL-HIP
version:2.1
email;internet:[EMAIL PROTECTED]
title:Developer
note:We don't use JAVA, We make JAVA usable.
adr;quoted-printable:;;D-3, Ground Floor=0D=0APrimrose Apartments,=0D=0A15, Ellaiyamman Koil Street,=0D=0AVannanthurai, Adyar;Chennai;Tamil Nadu;600 020;India
fn:Praveen Mohan
end:vcard