1

I'm trying to make steganography for .gif images. But I stuck when I want write/save changed image as animated gif. This sample of code pulls out separated images from gif but I can't figure out how to write them back to animated .gif image and save it.

File file = new File("gif1.gif");
ImageReader reader = ImageIO.getImageReadersBySuffix("GIF").next();
ImageInputStream in = ImageIO.createImageInputStream(file);
reader.setInput(in);


ImageWriter writer = ImageIO.getImageWritersBySuffix("GIF").next();
ImageOutputStream out = ImageIO.createImageOutputStream("new.gif");
writer.setOutput(out);

for (int i = 0, count = reader.getNumImages(true); i < count; i++)
{
    BufferedImage image = reader.read(i);
} 

I will be gratefull for any help.

Petr Šrámek
  • 435
  • 7
  • 26
  • You have no idea what you are getting your self into! Do your self a favor and use `ImageIcon` instead of `ImageIO`. http://stackoverflow.com/questions/22188940/gif-image-doesnt-moves-on-adding-it-to-the-jtabbed-pane/22190844#22190844 – Dima Maligin Mar 31 '15 at 15:05
  • 1
    http://stackoverflow.com/questions/777947/creating-animated-gif-with-imageio - using ImageIcon might be easier though... – BretC Mar 31 '15 at 15:13
  • 1
    @DimaMaligin In what way would using `ImageIcon` help with *writing* `BufferedImage`s to an animated GIF? – Harald K Mar 31 '15 at 17:35

0 Answers0