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 2017/10/26 15:51:00 UTC

[jira] [Updated] (PDFBOX-3981) It won't catch the exception when read the CMYK image in PDF for DCTFilter.class

     [ https://issues.apache.org/jira/browse/PDFBOX-3981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr updated PDFBOX-3981:
------------------------------------
    Description: 
In below code of DCTFilter.class, can't catch the IIOException because the right Exception is IOException. 

And when I change the code, in my testing, when I convert the PDF to image, I found the CMYK image will be lost in converted image, it's very strange when I set "String numChannels = '2'", I got positive result. 
{code}
            if ("3".equals(numChannels) || numChannels.isEmpty())
            {
                try
                {
                    // I'd like to use ImageReader#readRaster but it is buggy and can't read RGB correctly
                    BufferedImage image = reader.read(0);
                    raster = image.getRaster();
                }
                catch (IIOException e)
                {
                    // JAI can't read CMYK JPEGs using ImageReader#read or ImageIO.read but
                    // fortunately ImageReader#readRaster isn't buggy when reading 4-channel files
                    raster = reader.readRaster(0, null);
                }
            }
{code}


  was:
In below code of DCTFilter.class, can't catch the IIOException because the right Exception is IOException. 

And when I change the code, in my testing, when I convert the PDF to image, I found the CMYK image will be lost in converted image, it's very strange when I set "String numChannels = '2'", I got positive result. 

  if ("3".equals(numChannels) || numChannels.isEmpty())
            {
                try
                {
                    // I'd like to use ImageReader#readRaster but it is buggy and can't read RGB correctly
                    BufferedImage image = reader.read(0);
                    raster = image.getRaster();
                }
                catch (IIOException e)
                {
                    // JAI can't read CMYK JPEGs using ImageReader#read or ImageIO.read but
                    // fortunately ImageReader#readRaster isn't buggy when reading 4-channel files
                    raster = reader.readRaster(0, null);
                }
            }


> It won't catch the exception when read the CMYK image in PDF for DCTFilter.class
> --------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3981
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3981
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.7
>         Environment: Windows/Liunx
>            Reporter: austinchen
>              Labels: cmyk
>             Fix For: 2.0.7
>
>
> In below code of DCTFilter.class, can't catch the IIOException because the right Exception is IOException. 
> And when I change the code, in my testing, when I convert the PDF to image, I found the CMYK image will be lost in converted image, it's very strange when I set "String numChannels = '2'", I got positive result. 
> {code}
>             if ("3".equals(numChannels) || numChannels.isEmpty())
>             {
>                 try
>                 {
>                     // I'd like to use ImageReader#readRaster but it is buggy and can't read RGB correctly
>                     BufferedImage image = reader.read(0);
>                     raster = image.getRaster();
>                 }
>                 catch (IIOException e)
>                 {
>                     // JAI can't read CMYK JPEGs using ImageReader#read or ImageIO.read but
>                     // fortunately ImageReader#readRaster isn't buggy when reading 4-channel files
>                     raster = reader.readRaster(0, null);
>                 }
>             }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org