}
System.out.println("Writing to file.");
ImageOutputStream stream = null;
try {
stream = new FileImageOutputStream(file);
GifSequenceWriter writer = new GifSequenceWriter(stream, BufferedImage.TYPE_INT_RGB, 64, true);
for (BufferedImage img: imgs) {
writer.writeToSequence(img);
}
writer.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {