• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How can i know the data that is read from the .gif file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI ALL,

My project is image(.gif) file to DoC conversion
to read .gif file,imported and used Thirdparty package com.gif4j.
inorder to know the data that is read from the gif file i have used below two lines of code:
GifImage gifImage = GifDecoder.decode(file);
int j= gifImage.getNumberOfFrames();
String s=gifImage.getComment(j);
but it is throwing an exception saying that 'Exception in thread main'

what can i do now to know that data which i have read?
please suggest me!since i am a fresher,and my boss is not helping to me!

Regards,
kalyani.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which line is the Exception thrown?
 
kalyani guntupalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
here i am sending my code.exception is coming after printing the number of frames.
here is my code:

package gif.doc;
import com.gif4j.GifDecoder;
import com.gif4j.GifFrame;
import com.gif4j.GifImage;
import java.awt.image.IndexColorModel;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;

/**
* Load a GIF Image and Extract GIF File Format Meta Info
*/

public class GifImageLoad {

// Usage: java GifImageLoadExample [PathToGifImageToLoad] (please be sure that the gif4j jar is in your CLASSPATH)
// By default the gif4j_logotype.gif as an example gif image is used
public static void main(String[] args) {
if (args.length == 0) {
File gifImageFile = new File("D:/Myapps/read/4843a349.gif");
GifImageLoad gifImageLoadExample = new GifImageLoad();
try {

System.out.println("");
gifImageLoadExample.loadGifImageAndExtractMetaInfo(gifImageFile);
} catch (IOException e) {
e.printStackTrace();
}
} else {
GifImageLoad gifImageLoadExample = new GifImageLoad();
for (int i = 0; i < args.length; i++) {
File gifImageFile = new File(args[i]);
System.out.println("-------" + args[i] + "-------");
System.out.println("");
try {
gifImageLoadExample.loadGifImageAndExtractMetaInfo(gifImageFile);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("");
}

}

}

public GifImage loadGifImageAndExtractMetaInfo(File file) throws IOException {
// load and decode gif image from the file
GifImage gifImage = GifDecoder.decode(file);
// print general GIF image info
System.out.println("gif image format version: " + gifImage.getVersion());
System.out.println("gif image logic screen width: " + gifImage.getScreenWidth());
System.out.println("gif image logic screen height: " + gifImage.getScreenHeight());
// check if one or more comments present
if (gifImage.getNumberOfComments() > 0) {
// get iterator over gif image textual comments
Iterator commentsIterator = gifImage.comments();
while (commentsIterator.hasNext())
System.out.println(commentsIterator.next()); // print comments
}
System.out.println("number of frames: " + gifImage.getNumberOfFrames());
int j= gifImage.getNumberOfFrames();
String s=gifImage.getComment(j);

// below we iterate frames in loop
// but it can also be done using Iterator instance: gifImage.frames()
for (int i = 0; i < gifImage.getNumberOfFrames(); i++) {
System.out.println("------frame(" + (i + 1) + ")---------");
GifFrame frame = gifImage.getFrame(i);
System.out.println("width: " + frame.getWidth());
System.out.println("height: " + frame.getHeight());
System.out.println("position: " + frame.getX() + "," + frame.getY());
System.out.println("disposal method: " + frame.getDisposalMethod());
System.out.println("delay time: " + frame.getDelay());
System.out.println("is interlaced: " + frame.isInterlaced());


}
return gifImage;
}
}

Regards,
kalyani.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kalyani guntupalli:

My project is image(.gif) file to DoC conversion



The gif4j library does not convert GIF files to DOC files, so it will not get you any closer to your goal.
 
kalyani guntupalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but my boss asked me to show the content that is read in gif file by using that library gif4j.

He told that he could tell how to convert into doc file!
aftet showing the content of gif file...
can you please help me?

Regards,
kalyani
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

can you please help me?



I already have. What part of my answer do you have a problem with?
If you want to display an image, have a look at the Swing tutorial.
reply
    Bookmark Topic Watch Topic
  • New Topic