You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2014/08/26 21:19:58 UTC

[jira] [Comment Edited] (PDFBOX-2288) Defective BufferedImage for flate encoded images

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

Tilman Hausherr edited comment on PDFBOX-2288 at 8/26/14 7:19 PM:
------------------------------------------------------------------

Technically this is a java imageio bug. I don't see how it is related to Flate encoding. Apparently imageio can't handle our custom BufferedImage type correctly. It may be a different one for different images, see SampledImageReader, and the many toRGBImage() methods. We could modify that one, but I expect trouble, e.g. images no longer being identical before and after being used in a PDF.

All I can think about is 
1) to alter ImageIOUtils so that an RGB type BufferedImage is created before saving into .bmp only. But do you really use .bmp images in your application??? What for?
2) check whether the bug occurs with all availables writers for .bmp (there may be a different one for JAI)



was (Author: tilman):
Technically this is a java imageio bug. I don't see how it is related to Flate encoding. Apparently imageio can't handle our custom BufferedImage type correctly. It may be a different one for different images, see SampledImageReader, and the many toRGBImage() methods. We could modify that one, but I expect trouble, e.g. images no longer being identical before and after being used in a PDF.

All I can think about is 
1) to alter ImageIOUtils so that an RGB type BufferedImage is created before saving into .bmp only. But do you really use .bmp images in your application??? What for?
2) check whether the bug with all availables writers for .bmp (there may be a different one for JAI)


> Defective BufferedImage for flate encoded images
> ------------------------------------------------
>
>                 Key: PDFBOX-2288
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2288
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.0
>            Reporter: Dominic Tubach
>         Attachments: test.pdf
>
>
> The BufferedImages for flate encoded images seem to be defective. The following code results in a ArrayIndexOutOfBoundsException when writing the image:
> {code}
> PDDocument doc = PDDocument.load("test.pdf");
> Iterator<PDXObject> it = doc.getPage(0).getResources().getXObjects().values().iterator();
> PDImageXObject image = (PDImageXObject) it.next();
> BufferedImage bi = image.getImage();
> try (FileOutputStream fos = new FileOutputStream("test.bmp")) {
>     ImageIO.write(bi, "bmp", fos);
> }
> {code}
> The problem did not exist in 1.8. The attached PDF just contains one flate encoded image.



--
This message was sent by Atlassian JIRA
(v6.2#6252)