jai-imageio / jai-imageio-jpeg2000

JPEG2000 support for Java Advanced Imaging Image I/O Tools API
Other
74 stars 56 forks source link

java.lang.OutOfMemoryError: Java heap space #44

Open Lychengit opened 1 year ago

Lychengit commented 1 year ago

jvm:-Xmx600m

demo:

public static void main(String[] args) throws IOException {

    ImageInputStream iis = ImageIO.createImageInputStream(new File("D:\\fcs\\test\\test6\\test.jpeg"));

    Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
    if (!readers.hasNext())
    {
        throw new RuntimeException("No suitable ImageReader found for source data.");
    }

    ImageReader reader = readers.next();

    reader.setInput(iis, true, true);
    ImageReadParam irp = reader.getDefaultReadParam();
    irp.setSourceRegion(null);
    irp.setSourceSubsampling(2, 2,
            0, 0);

    BufferedImage image;
    try
    {
        image = reader.read(0, irp);
    }
    catch (Exception e)
    {
        // wrap and rethrow any exceptions
        throw new IOException("Could not read JPEG 2000 (JPX) image", e);
    }
    ImageIO.write(image, "jpeg", new File("D:\\fcs\\test\\test6\\1.jpeg"));
}

image file: test.zip

Lychengit commented 1 year ago

The source file is in the zip archive, please unzip it and test it

Lychengit commented 1 year ago

I also can't control the overflow point using subsampling

Lychengit commented 1 year ago

Is there any way to fix this overflow point

Lychengit commented 1 year ago

image