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

John Hewson edited comment on PDFBOX-1734 at 2/13/14 12:59 AM:
---------------------------------------------------------------

That's a shame. I took another look at Apache XML Graphics Commons because I 
was surprised when you said that they only support Packbits and Deflate. It 
turns out that Sun's TIFF code which was donated to the project in 2001 was 
never updated, and the 2005 release of JAI supports more compression types:

>From Sun's 2005 TIFFImageWriter.java:
{code}
/**
 * Supported TIFF compression types.
 */
public static final String[] TIFFCompressionTypes = {
    "CCITT RLE",
    "CCITT T.4",
    "CCITT T.6",
    "LZW",
    // "Old JPEG",
    "JPEG",
    "ZLib",
    "PackBits",
    "Deflate",
    EXIF_JPEG_COMPRESSION_TYPE
};
{code}

Indeed, the 2005 release of JAI contains exactly those com.sun.* classes which 
you began with. So I think that using those classes will work for you. However, 
don't import them directly, use the generic JAI metadata API to set whatever 
parameters you need, exactly as is done in 
https://svn.apache.org/repos/asf/xmlgraphics/commons/tags/commons-1_3_1/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java


was (Author: jahewson):
That's a shame. I took another look at Apache XML Graphics Commons because I 
was surprised when you said that they only support Packbits and Deflate. It 
turns out that Sun's TIFF code which was donated to the project in 2001 was 
never updated, and the 2005 release of JAI supports more compression types:

>From TIFFImageWriter.java:
{code}
/**
 * Supported TIFF compression types.
 */
public static final String[] TIFFCompressionTypes = {
    "CCITT RLE",
    "CCITT T.4",
    "CCITT T.6",
    "LZW",
    // "Old JPEG",
    "JPEG",
    "ZLib",
    "PackBits",
    "Deflate",
    EXIF_JPEG_COMPRESSION_TYPE
};
{code}

Indeed, the 2005 release of JAI contains exactly those com.sun.* classes which 
you began with. So I think that using those classes will work for you. However, 
don't import them directly, use the generic JAI metadata API to set whatever 
parameters you need, exactly as is done in 
https://svn.apache.org/repos/asf/xmlgraphics/commons/tags/commons-1_3_1/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java

> 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
>          Components: Rendering
>         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