"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.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.

ImageIOUtil.java  (pdfbox-2.0.23-src):ImageIOUtil.java  (pdfbox-2.0.24-src)
skipping to change at line 282 skipping to change at line 282
break; break;
} }
} }
if (writer == null) if (writer == null)
{ {
LOG.error("No ImageWriter found for '" + formatName + "' format" ); LOG.error("No ImageWriter found for '" + formatName + "' format" );
LOG.error("Supported formats: " + Arrays.toString(ImageIO.getWri terFormatNames())); LOG.error("Supported formats: " + Arrays.toString(ImageIO.getWri terFormatNames()));
return false; return false;
} }
boolean isTifFormat = formatName.toLowerCase().startsWith("tif");
// compression // compression
if (param != null && param.canWriteCompressed()) if (param != null && param.canWriteCompressed())
{ {
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
if (formatName.toLowerCase().startsWith("tif")) if (isTifFormat)
{ {
if ("".equals(compressionType)) if ("".equals(compressionType))
{ {
// default logic // default logic
TIFFUtil.setCompressionType(param, image); TIFFUtil.setCompressionType(param, image);
} }
else else
{ {
param.setCompressionType(compressionType); param.setCompressionType(compressionType);
if (compressionType != null) if (compressionType != null)
skipping to change at line 309 skipping to change at line 311
} }
} }
} }
else else
{ {
param.setCompressionType(param.getCompressionTypes()[0]); param.setCompressionType(param.getCompressionTypes()[0]);
param.setCompressionQuality(compressionQuality); param.setCompressionQuality(compressionQuality);
} }
} }
if (formatName.toLowerCase().startsWith("tif")) if (metadata != null)
{
// TIFF metadata
TIFFUtil.updateMetadata(metadata, image, dpi);
}
else if ("jpeg".equalsIgnoreCase(formatName)
|| "jpg".equalsIgnoreCase(formatName))
{ {
// This segment must be run before other meta operations, if (isTifFormat)
// or else "IIOInvalidTreeException: Invalid node: app0JFIF" {
// The other (general) "meta" methods may not be used, because // TIFF metadata
// this will break the reading of the meta data in tests TIFFUtil.updateMetadata(metadata, image, dpi);
JPEGUtil.updateMetadata(metadata, dpi); }
} else if ("jpeg".equalsIgnoreCase(formatName) || "jpg".equalsIgno
else reCase(formatName))
{ {
// write metadata is possible // This segment must be run before other meta operations,
if (metadata != null // or else "IIOInvalidTreeException: Invalid node: app0JFIF"
&& !metadata.isReadOnly() // The other (general) "meta" methods may not be used, becau
&& metadata.isStandardMetadataFormatSupported()) se
// this will break the reading of the meta data in tests
JPEGUtil.updateMetadata(metadata, dpi);
}
else
{ {
setDPI(metadata, dpi, formatName); // write metadata is possible
if (!metadata.isReadOnly() && metadata.isStandardMetadataFor
matSupported())
{
setDPI(metadata, dpi, formatName);
}
} }
} }
if (metadata != null && formatName.equalsIgnoreCase("png") && hasICC Profile(image)) if (metadata != null && formatName.equalsIgnoreCase("png") && hasICC Profile(image))
{ {
// add ICC profile // add ICC profile
IIOMetadataNode iccp = new IIOMetadataNode("iCCP"); IIOMetadataNode iccp = new IIOMetadataNode("iCCP");
ICC_Profile profile = ((ICC_ColorSpace) image.getColorModel().ge tColorSpace()) ICC_Profile profile = ((ICC_ColorSpace) image.getColorModel().ge tColorSpace())
.getProfile(); .getProfile();
iccp.setUserObject(getAsDeflatedBytes(profile)); iccp.setUserObject(getAsDeflatedBytes(profile));
 End of changes. 5 change blocks. 
21 lines changed or deleted 26 lines changed or added

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