pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1802511 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java
Date Thu, 20 Jul 2017 16:07:24 GMT
Author: tilman
Date: Thu Jul 20 16:07:24 2017
New Revision: 1802511

URL: http://svn.apache.org/viewvc?rev=1802511&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/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java?rev=1802511&r1=1802510&r2=1802511&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java Thu Jul
20 16:07:24 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.util.MetaUtil.SUN_TIFF_FORMAT;
 import static org.apache.pdfbox.util.MetaUtil.debugLogMetadata;
 
 /**
@@ -35,22 +34,6 @@ class TIFFUtil
 {
     private static final Log LOG = LogFactory.getLog(TIFFUtil.class);
 
-    private static String tagSetClassName = "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet";
-    
-    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
@@ -84,20 +67,20 @@ class TIFFUtil
      */
     public static void updateMetadata(IIOMetadata metadata, BufferedImage image, int dpi)
     {
-        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
@@ -123,7 +106,7 @@ class TIFFUtil
         
         try
         {
-            metadata.mergeTree(SUN_TIFF_FORMAT, root);
+            metadata.mergeTree(metaDataFormat, root);
         }
         catch (IIOInvalidTreeException e)
         {
@@ -131,7 +114,7 @@ class TIFFUtil
             throw new RuntimeException(e);
         }
 
-        debugLogMetadata(metadata, SUN_TIFF_FORMAT);
+        debugLogMetadata(metadata, metaDataFormat);
     }
 
     private static IIOMetadataNode createShortField(int tiffTagNumber, String name, int val)



Mime
View raw message