dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
204 stars 58 forks source link

java.lang.OutOfMemoryError: Java heap space #23

Closed kpassoubady closed 8 years ago

kpassoubady commented 8 years ago

Hi, In your document, you have said, " To save memory, we can also write animated GIF frame by frame!" Can you provide an example? I'm getting Java Heap Space error due to all the images are written out in a single shot. GIFTweaker.writeAnimatedGIF(images, delays, fout);

Thanks Kangs

dragon66 commented 8 years ago

@kpassoubady, you can do something like this:

FileOutputStream fout; // Initiate output file
BufferedImage bi; // Grab a BufferedImage somewhere
GIFWriter animatedGIFWriter = new GIFWriter(); 
animatedGIFWriter.setImageParam(builder.applyDither(true).build()); 
// Set logical screen width and height to zero to use first frame width and height  
GIFTweaker.prepareForWrite(animatedGIFWriter, fout, 0, 0);
// Keep writing frames until done
GIFTweaker.writeFrame(animatedGIFWriter, fout, bi);
// In the end, wrap it up 
GIFTweaker.finishWrite(fout); 
fout.close();
kpassoubady commented 8 years ago

Thank You so much. Your input helped a lot.

Thanks Kangs

Kangeyan Passoubady

On Tue, Dec 1, 2015 at 8:27 AM, dragon66 notifications@github.com wrote:

Closed #23 https://github.com/dragon66/icafe/issues/23.

— Reply to this email directly or view it on GitHub https://github.com/dragon66/icafe/issues/23#event-479146724.