Can’t import javax.imageio.ImageIO in Android application

You have tagged your question with Android. javax.imageio.ImageIO is not part of the Android platform, so unfortunately you can’t use it. Instead you need to use what’s available in the Android SDK for reading and storing images. Have a look at the Bitmap and BitmapFactory classes for a starting point. These classes contains the necessary … Read more

Convert each animated GIF frame to a separate BufferedImage

If you want all the frames to be the same size (for optimized GIFs) try something like this: try { String[] imageatt = new String[]{ “imageLeftPosition”, “imageTopPosition”, “imageWidth”, “imageHeight” }; ImageReader reader = (ImageReader)ImageIO.getImageReadersByFormatName(“gif”).next(); ImageInputStream ciis = ImageIO.createImageInputStream(new File(“house2.gif”)); reader.setInput(ciis, false); int noi = reader.getNumImages(true); BufferedImage master = null; for (int i = 0; i … Read more

Java/ImageIO getting image dimensions without reading the entire file?

try(ImageInputStream in = ImageIO.createImageInputStream(resourceFile)){ final Iterator<ImageReader> readers = ImageIO.getImageReaders(in); if (readers.hasNext()) { ImageReader reader = readers.next(); try { reader.setInput(in); return new Dimension(reader.getWidth(0), reader.getHeight(0)); } finally { reader.dispose(); } } } Thanks to sfussenegger for the suggestion