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

Tilman Hausherr commented on PDFBOX-1734:
-----------------------------------------

Any arguments against using Apache Imaging instead of imageio?
https://commons.apache.org/proper/commons-imaging/

Pro: 
- its an Apache project
- easy to use
- it does support writing the resolution and choosing a TIFF compression
- doesn't use buggy java imaging
- ImageIOUtil gets much shorter

Minus:
- additional library, with size 674 KB

Its important to support TIFF; although the format feels like the car designed 
by Homer Simpson, it is popular in document archiving applications, especially 
the G4 compression.

{code}
            ImageFormat imf = ...... choose one ....
            Map<String, Object> params = new HashMap<String, Object>();
            params.put(ImagingConstants.PARAM_KEY_PIXEL_DENSITY, 
PixelDensity.createFromPixelsPerInch(resolution, resolution));
            if (imf == ImageFormats.TIFF)
            {
                if (image.getType() == BufferedImage.TYPE_BYTE_BINARY)
                {
                    params.put(ImagingConstants.PARAM_KEY_COMPRESSION, 
TiffConstants.TIFF_COMPRESSION_CCITT_GROUP_4);
                }
                else
                {
                    params.put(ImagingConstants.PARAM_KEY_COMPRESSION, 
TiffConstants.TIFF_COMPRESSION_LZW);
                }
            }
            Imaging.writeImage(image, (File) outputStream, imf, params);
{code}

> ImageIoUtil.WriteImage doesn't work with tiff images
> ----------------------------------------------------
>
>                 Key: PDFBOX-1734
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1734
>             Project: PDFBox
>          Issue Type: Improvement
>         Environment: XP, W7
>            Reporter: Tilman Hausherr
>            Priority: Minor
>              Labels: tiff
>         Attachments: ImageIOUtil.patch, TestImageIOUtils.patch
>
>
> ImageIoUtil.WriteImage brings an I/O error exception when trying to write a 
> tiff file. Debugging shows that the cause is "Bits per sample must be 1 for 
> RLE compression!". This means that the compression used (the first one of the 
> following list, returned by writerParams.getCompressionTypes() ) is only 
> allowed for bitonal images.
> CCITT RLE
> CCITT T.4
> CCITT T.6
> LZW
> JPEG
> ZLib
> PackBits
> Deflate
> EXIF JPEG
> After correcting this, the next problem was that tiff images didn't have the 
> proper resolutions. I added that too. Yes it uses the com.sun.* classes; 
> however there is no other way. Even apache xmlgraphics uses them, although in 
> a very different way than I do
> https://svn.apache.org/repos/asf/xmlgraphics/commons/tags/commons-1_3_1/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java
> writeImage() has a parameter "int imageType" which is never used. Why?



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to