You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2017/07/20 15:47:15 UTC

svn commit: r1802510 - /pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java

Author: tilman
Date: Thu Jul 20 15:47:15 2017
New Revision: 1802510

URL: http://svn.apache.org/viewvc?rev=1802510&view=rev
Log:
PDFBOX-3584: support new metadata format from jdk9 (javax_imageio_tiff_image_1.0); remove unneeded BaselineTIFFTagSet classes: "By default, the tag sets BaselineTIFFTagSet (...) are included."

Modified:
    pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java

Modified: pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java?rev=1802510&r1=1802509&r2=1802510&view=diff
==============================================================================
--- pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java (original)
+++ pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java Thu Jul 20 15:47:15 2017
@@ -24,7 +24,6 @@ import javax.imageio.metadata.IIOInvalid
 import javax.imageio.metadata.IIOMetadata;
 import javax.imageio.metadata.IIOMetadataNode;
 import java.awt.image.BufferedImage;
-import static org.apache.pdfbox.tools.imageio.MetaUtil.SUN_TIFF_FORMAT;
 import static org.apache.pdfbox.tools.imageio.MetaUtil.debugLogMetadata;
 
 /**
@@ -35,26 +34,10 @@ final class TIFFUtil
 {
     private static final Log LOG = LogFactory.getLog(TIFFUtil.class);
 
-    private static String tagSetClassName = "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet";
-    
     private TIFFUtil()
     {
     }    
 
-    static
-    {
-        try
-        {
-            String alternateClassName = "com.github.jaiimageio.plugins.tiff.BaselineTIFFTagSet";
-            Class.forName(alternateClassName);
-            tagSetClassName = alternateClassName;
-        }
-        catch (ClassNotFoundException ex)
-        {
-            // ignore
-        }
-    }
-
     /**
      * Sets the ImageIO parameter compression type based on the given image.
      * @param image buffered image used to decide compression type
@@ -92,20 +75,20 @@ final class TIFFUtil
     static void updateMetadata(IIOMetadata metadata, BufferedImage image, int dpi)
             throws IIOInvalidTreeException
     {
-        debugLogMetadata(metadata, SUN_TIFF_FORMAT);
-
-        if (!SUN_TIFF_FORMAT.equals(metadata.getNativeMetadataFormatName()))
+        String metaDataFormat = metadata.getNativeMetadataFormatName();
+        if (metaDataFormat == null)
         {
-            LOG.debug("Using unknown TIFF image writer: " + metadata.getNativeMetadataFormatName());
+            LOG.debug("TIFF image writer doesn't support any data format");
             return;
         }
 
-        IIOMetadataNode root = new IIOMetadataNode(SUN_TIFF_FORMAT);
+        debugLogMetadata(metadata, metaDataFormat);
+
+        IIOMetadataNode root = new IIOMetadataNode(metaDataFormat);
         IIOMetadataNode ifd;
         if (root.getElementsByTagName("TIFFIFD").getLength() == 0)
         {
             ifd = new IIOMetadataNode("TIFFIFD");
-            ifd.setAttribute("tagSets", tagSetClassName);
             root.appendChild(ifd);
         }
         else
@@ -129,9 +112,9 @@ final class TIFFUtil
             ifd.appendChild(createShortField(262, "PhotometricInterpretation", 0));
         }
         
-        metadata.mergeTree(SUN_TIFF_FORMAT, root);
+        metadata.mergeTree(metaDataFormat, root);
         
-        debugLogMetadata(metadata, SUN_TIFF_FORMAT);
+        debugLogMetadata(metadata, metaDataFormat);
     }
 
     private static IIOMetadataNode createShortField(int tiffTagNumber, String name, int val)