"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

JPEGFactory.java  (pdfbox-2.0.23-src):JPEGFactory.java  (pdfbox-2.0.24-src)
skipping to change at line 227 skipping to change at line 227
} }
Element root = (Element) imageMetadata.getAsTree("javax_imageio_jpeg_ima ge_1.0"); Element root = (Element) imageMetadata.getAsTree("javax_imageio_jpeg_ima ge_1.0");
if (root == null) if (root == null)
{ {
return 0; return 0;
} }
try try
{ {
XPath xpath = XPathFactory.newInstance().newXPath(); XPath xpath = XPathFactory.newInstance().newXPath();
String numScanComponents = xpath.evaluate("markerSequence/sos/@numSc String numFrameComponents = xpath.evaluate("markerSequence/sof/@numF
anComponents", root); rameComponents", root);
if (numScanComponents.isEmpty()) if (numFrameComponents.isEmpty())
{ {
return 0; return 0;
} }
return Integer.parseInt(numScanComponents); return Integer.parseInt(numFrameComponents);
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
LOG.warn(ex.getMessage(), ex); LOG.warn(ex.getMessage(), ex);
return 0; return 0;
} }
catch (XPathExpressionException ex) catch (XPathExpressionException ex)
{ {
LOG.warn(ex.getMessage(), ex); LOG.warn(ex.getMessage(), ex);
return 0; return 0;
skipping to change at line 363 skipping to change at line 363
{ {
PDImage xAlpha = JPEGFactory.createFromImage(document, awtAlphaImage , quality); PDImage xAlpha = JPEGFactory.createFromImage(document, awtAlphaImage , quality);
pdImage.getCOSObject().setItem(COSName.SMASK, xAlpha); pdImage.getCOSObject().setItem(COSName.SMASK, xAlpha);
} }
return pdImage; return pdImage;
} }
private static ImageWriter getJPEGImageWriter() throws IOException private static ImageWriter getJPEGImageWriter() throws IOException
{ {
ImageWriter writer = null;
Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("jpeg"); Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("jpeg");
while (writers.hasNext()) while (writers.hasNext())
{ {
if (writer != null) ImageWriter writer = writers.next();
{
writer.dispose();
}
writer = writers.next();
if (writer == null) if (writer == null)
{ {
continue; continue;
} }
// PDFBOX-3566: avoid CLibJPEGImageWriter, which is not a JPEGImageW riteParam // PDFBOX-3566: avoid CLibJPEGImageWriter, which is not a JPEGImageW riteParam
if (writer.getDefaultWriteParam() instanceof JPEGImageWriteParam) if (writer.getDefaultWriteParam() instanceof JPEGImageWriteParam)
{ {
return writer; return writer;
} }
writer.dispose();
} }
throw new IOException("No ImageWriter found for JPEG format"); throw new IOException("No ImageWriter found for JPEG format");
} }
private static void encodeImageToJPEGStream(BufferedImage image, float quali ty, int dpi, private static void encodeImageToJPEGStream(BufferedImage image, float quali ty, int dpi,
OutputStream out) throws IOExcep tion OutputStream out) throws IOExcep tion
{ {
// encode to JPEG // encode to JPEG
ImageOutputStream ios = null; ImageOutputStream ios = null;
ImageWriter imageWriter = null; ImageWriter imageWriter = null;
 End of changes. 5 change blocks. 
10 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)