You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2011/01/30 18:10:46 UTC

[jira] Resolved: (PDFBOX-942) Image quality improvements

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

Andreas Lehmkühler resolved PDFBOX-942.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5.0
         Assignee: Andreas Lehmkühler

I added the patch in revison 1065318. 

I made some slight modifications by adding a new constructor to set the compression level. The default level is still 0.75

Thanks for the contribution!

> Image quality improvements
> --------------------------
>
>                 Key: PDFBOX-942
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-942
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.4.0
>            Reporter: Olivier DOREMIEUX
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.5.0
>
>         Attachments: PDJpeg.patch
>
>
> The quality of the images inserted in a PDF documents could be improved by changing PDJpeg.java
> In the API
> public PDJpeg(PDDocument doc, BufferedImage bi) throws IOException
> ImageIO.write(bi, "jpeg", os);
> could be replaced by :
>               ImageWriter writer = null;
>               Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
>               if (iter.hasNext()) {
>                   writer = (ImageWriter) iter.next();
>               }
>  
>               ImageOutputStream ios = ImageIO.createImageOutputStream(os);
>               writer.setOutput(ios);
>  
>               // Set the compression quality
>               JPEGImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
>               iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
>               iwparam.setCompressionQuality(1.0f);
>  
>               // Write the image
>               writer.write(null, new IIOImage(bi, null, null), iwparam);
>  
>               writer.dispose();
> This increase the size of the generated PDF.
> By default the JPEG quality is 0.75, in the patch I use 1.0, the maximum quality
> As a suggestion the quality of the JPEG could be a global variable since it affect the size of the PDF

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.