Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does ImageReader return incorrect BufferedImage?
    primarykey
    data
    text
    <p>I'm trying to access a animated GIF image with 21 frames and then read the 12th (cause it starts at 0?) frame.</p> <pre><code>import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.SuffixFileFilter; import org.apache.commons.io.filefilter.TrueFileFilter; public class PictureSearch { public static void search(File file) { try { ImageReader reader = (ImageReader) ImageIO.getImageReadersBySuffix("gif").next(); reader.setInput(ImageIO.createImageInputStream(file), false); BufferedImage caption = reader.read(12); System.out.println(caption.getHeight()); System.out.println(caption.getWidth()); caption.flush(); } catch (IOException e) { System.out.println(e); } } public static void main(String[] args) throws IOException { List&lt;String&gt; suffixes = new ArrayList&lt;String&gt;(); suffixes.add(".jpg"); suffixes.add(".gif"); suffixes.add(".bmp"); suffixes.add(".png"); Iterator&lt;File&gt; files = FileUtils.iterateFiles(new File( "F:/test/"), (IOFileFilter) new SuffixFileFilter( suffixes), TrueFileFilter.INSTANCE); while (files.hasNext()) { File file = (File) files.next(); PictureSearch.search(file); } } } </code></pre> <p>The reader should return me a buffered image with height 220 and width 200 (or height 205 and width 188 if it ignores white fields around the image). But what it does is it returns me a image of height 155 and width 174 what is absurd because i triple checked and the frame 12 is height 220 and width 200. Am I doing everything correctly in reading the frames?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload