• Post Reply Bookmark Topic Watch Topic
  • New Topic

ImageIO.write and 0 byte gif file  RSS feed

 
Steve Yu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read this from web --
Hi everyone, I'm trying to save a BufferedImage as a GIF via javax.imageio.ImageIO, but I only
get "empty" files (files are created, but have size 0). This is my code:

Any ideas what my mistakes are?
Best thanks, Carsten
I had a similar problem myself when I am writing a photo store application. Is it a coding problem or hardware problem ?
[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ April 22, 2004: Message edited by: Jessica Sant ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but perhaps you need to call something like:
buffer.flush ();
Another error might be not to have a reference to your file, to close it (which migth flush automatically):
File ifile = new File (....);
// write the gif
ifile.close ();
A 3rd suggestion is, not to call dispose (); on the image before writing the image to the file.
Did something work?
 
Mike Fuellbrandt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's because the JDK doesn't come with a GIF encoder, because of licensing issues.
Iterate over the ImageIO.getWriterFormatNames() array and see what you have access to. Should be jpg & png, unless you've been able to add encoders
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!