commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrian Costil (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IMAGING-113) Cannot read multipage tiff
Date Tue, 22 Oct 2013 13:56:42 GMT

    [ https://issues.apache.org/jira/browse/IMAGING-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13801830#comment-13801830
] 

Adrian Costil commented on IMAGING-113:
---------------------------------------

the patch seems to work.
I was facing another issue with my test tiff image which has 14 images, each 3386 x 4397.
The library uses a lot of memory for  Imaging.getAllBufferedImages(new File(imageLocation));
so I had to start the JVM with a lot of memory to process a single image file.
-Xms512m
-Xmx1024m

Is there a way to improve the memory usage ?

Also I was trying to write to a different file and it seems that it will write only the last
image. Is there a way to append the images to a tiff file ?

this is a sample code:
final List<BufferedImage> images = Imaging.getAllBufferedImages(new File(imageLocation));
			
            
			final ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
	        final Map<String,Object> params = new HashMap<String,Object>();

	        // set optional parameters if you like
	        params.put(ImagingConstants.PARAM_KEY_COMPRESSION, new Integer(
	                TiffConstants.TIFF_COMPRESSION_LZW));

	        int i= 0;
	        File outFile = new File(outLocation);
	        for (Iterator<BufferedImage> iterator = images.iterator(); iterator.hasNext();
i++) {
				BufferedImage bufferedImage = iterator.next();
		        System.out.println("write image " + i);
		        Imaging.writeImage(bufferedImage, outFile, format, params);
			}



> Cannot read multipage tiff
> --------------------------
>
>                 Key: IMAGING-113
>                 URL: https://issues.apache.org/jira/browse/IMAGING-113
>             Project: Commons Imaging
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Adrian Costil
>              Labels: multipage, tiff
>             Fix For: 1.0
>
>
> I get the error below when I'm trying to read a multipage tiff file as a list of images
> 			final List<BufferedImage> images = Imaging.getAllBufferedImages(new File(imageLocation));
> line 589 of TiffImageParser
>         Rectangle subImage = checkForSubImage(params); //if the params is null it will
crash
> java.lang.NullPointerException
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getIntegerParameter(TiffImageParser.java:513)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.checkForSubImage(TiffImageParser.java:531)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:589)
> 	at org.apache.commons.imaging.formats.tiff.TiffDirectory.getTiffImage(TiffDirectory.java:163)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getAllBufferedImages(TiffImageParser.java:499)
> 	at org.apache.commons.imaging.Imaging.getAllBufferedImages(Imaging.java:1210)
> 	at org.apache.commons.imaging.Imaging.getAllBufferedImages(Imaging.java:1202)
> 	at TestWriteTiffImages.main(TestWriteTiffImages.java:30)



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message