[ https://issues.apache.org/jira/browse/PDFBOX-942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Olivier DOREMIEUX updated PDFBOX-942: ------------------------------------- Attachment: PDJpeg.patch > 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 > 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.