commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Lucas (JIRA)" <>
Subject [jira] [Commented] (IMAGING-126) TIFF and PNG images should not be bigger than the ones created by java ImageIO
Date Mon, 24 Feb 2014 20:36:19 GMT


Gary Lucas commented on IMAGING-126:

I don't have a solution just yet, but I may have an idea...

Can you include a code snippet showing which of the Apache Commons imaging API's you are using
to do your writing?  Are you using the main Imaging class, or one of the internal format-specific
image writers?

I might have some insight in terms of TIFF images.  I'm not sure about PNGs. The original
authors of the API set up their method calls so that you would pass in a HashMap containing
options for storing files.  Unless you pass in an option for data compression, it isn't applied
(at least for TIFFs, I am not sure about PNGs).

 To make that happen, you need to pass in a compression parameter into the writeImage call.
      The following is what I do in my ow code which uses one of the internal TiffWriter classes.
 You could probably do something analogous if you were using the main Image class.

HashMap<String, Object> params = new HashMap<String, Object>();
                    new Integer(TiffConstants.TIFF_COMPRESSION_LZW));

TiffimageWriterLossy tiffWriter = new TiffImageWriterLossy(eTiffByteOrder);

tiffWriter.writeImage(outputImage, outputFileStream, params);

> TIFF and PNG images should not be bigger than the ones created by java ImageIO
> ------------------------------------------------------------------------------
>                 Key: IMAGING-126
>                 URL:
>             Project: Commons Imaging
>          Issue Type: Improvement
>          Components: Format: PNG, Format: TIFF
>    Affects Versions: 1.0
>         Environment: W7
>            Reporter: Tilman Hausherr
>            Priority: Minor
>         Attachments: pdfbox-1870-devicen3-01.png, pdfbox-1870-devicen3-01.tif, pdfbox-1870-devicen3.pdf-1.png,
> I tried to use Apache Imaging for the PDFBOX project (PDFBOX-1734) because of problems
with setting the tiff resolution in java imageio.
> While the code is pretty nice, I found that the generated images are sometimes much bigger
in size than the ones generated by java imageio.
> Example:
> pdfbox-1870-devicen3-01.png 50 KB (imageio)
> pdfbox-1870-devicen3.pdf-1.png 70 KB (imaging)
> pdfbox-1870-devicen3-01.tif 401 KB (imageio)
> pdfbox-1870-devicen3.pdf-1.tif 1063 KB (imaging)

This message was sent by Atlassian JIRA

View raw message