pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1630259 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/ pdfbox/src/main/java/org/apache/pdfbox/util/ pdfbox/src/test/java/org/apache/pdfbox/ pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ ...
Date Thu, 09 Oct 2014 00:16:28 GMT
Author: jahewson
Date: Thu Oct  9 00:16:27 2014
New Revision: 1630259

URL: http://svn.apache.org/r1630259
Log:
PDFBOX-2387: Move imageio utilities to pdfbox.tools

Added:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.java
      - copied, changed from r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ImageIOUtil.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java
      - copied, changed from r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/JPEGUtil.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java
      - copied, changed from r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java
      - copied, changed from r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java
    pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/TestImageIOUtils.java
      - copied, changed from r1630256, pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
    pdfbox/trunk/tools/src/test/resources/input/
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/JBIG2Image.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JBIG2Image.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/jpeg_demo.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/jpeg_demo.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/png_demo.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/png_demo.pdf
    pdfbox/trunk/tools/src/test/resources/input/ImageIOUtil/raw_image_demo.pdf
      - copied unchanged from r1630256, pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/raw_image_demo.pdf
Removed:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ImageIOUtil.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/JPEGUtil.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/NullOutputStream.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JBIG2Image.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestCMYK.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestGrey.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/JPXTestRGB.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/ccitt4-cib-test.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/jpeg_demo.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/png_demo.pdf
    pdfbox/trunk/pdfbox/src/test/resources/input/ImageIOUtil/raw_image_demo.pdf
Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImageTest.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
Thu Oct  9 00:16:27 2014
@@ -23,8 +23,15 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Iterator;
 
+import javax.imageio.IIOImage;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
+import javax.imageio.stream.ImageOutputStream;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.filter.MissingImageReaderException;
 import org.apache.pdfbox.io.IOUtils;
@@ -32,7 +39,7 @@ import org.apache.pdfbox.pdmodel.PDDocum
 import javax.imageio.ImageIO;
 import javax.imageio.ImageReader;
 import javax.imageio.stream.ImageInputStream;
-import org.apache.pdfbox.util.ImageIOUtil;
+import org.w3c.dom.Element;
 
 /**
  * Factory for creating a PDImageXObject containing a JPEG compressed image.
@@ -170,10 +177,12 @@ public final class JPEGFactory extends I
         }
         if (image.getTransparency() == Transparency.BITMASK)
         {
-            throw new UnsupportedOperationException("BITMASK Transparency JPEG compression
is not useful, use LosslessImageFactory instead");
+            throw new UnsupportedOperationException("BITMASK Transparency JPEG compression
is not" +
+                    " useful, use LosslessImageFactory instead");
         }
         WritableRaster alphaRaster = image.getAlphaRaster();
-        BufferedImage alphaImage = new BufferedImage(image.getWidth(), image.getHeight(),
BufferedImage.TYPE_BYTE_GRAY);
+        BufferedImage alphaImage = new BufferedImage(image.getWidth(), image.getHeight(),
+                BufferedImage.TYPE_BYTE_GRAY);
         alphaImage.setData(alphaRaster);
         return alphaImage;
     }
@@ -188,7 +197,7 @@ public final class JPEGFactory extends I
 
         // create XObject
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ImageIOUtil.writeImage(awtColorImage, "jpeg", baos, dpi, quality);
+        encodeImageToJPEGStream(awtColorImage, quality, dpi, baos);
         ByteArrayInputStream byteStream = new ByteArrayInputStream(baos.toByteArray());
         
         
@@ -206,4 +215,49 @@ public final class JPEGFactory extends I
 
         return pdImage;
     }
+
+    private static void encodeImageToJPEGStream(BufferedImage image, float quality, int dpi,
+                                                OutputStream out) throws IOException
+    {
+        // encode to JPEG
+        ImageOutputStream ios = null;
+        ImageWriter imageWriter = null;
+        try
+        {
+            // find JAI writer
+            imageWriter = ImageIO.getImageWritersBySuffix("jpeg").next();
+            ios = ImageIO.createImageOutputStream(out);
+            imageWriter.setOutput(ios);
+
+            // add compression
+            JPEGImageWriteParam jpegParam = (JPEGImageWriteParam)imageWriter.getDefaultWriteParam();
+            jpegParam.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT);
+            jpegParam.setCompressionQuality(quality);
+
+            // add metadata
+            ImageTypeSpecifier imageTypeSpecifier = new ImageTypeSpecifier(image);
+            IIOMetadata data = imageWriter.getDefaultImageMetadata(imageTypeSpecifier, jpegParam);
+            Element tree = (Element)data.getAsTree("javax_imageio_jpeg_image_1.0");
+            Element jfif = (Element)tree.getElementsByTagName("app0JFIF").item(0);
+            jfif.setAttribute("Xdensity", Integer.toString(dpi));
+            jfif.setAttribute("Ydensity", Integer.toString(dpi));
+            jfif.setAttribute("resUnits", "1"); // 1 = dots/inch
+
+            // write
+            imageWriter.write(data, new IIOImage(image, null, null), jpegParam);
+        }
+        finally
+        {
+            // clean up
+            IOUtils.closeQuietly(out);
+            if (ios != null)
+            {
+                ios.close();
+            }
+            if (imageWriter != null)
+            {
+                imageWriter.dispose();
+            }
+        }
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/TestAll.java Thu Oct  9 00:16:27 2014
@@ -38,7 +38,6 @@ import org.apache.pdfbox.pdmodel.edit.Te
 import org.apache.pdfbox.pdmodel.graphics.optionalcontent.TestOptionalContentGroups;
 import org.apache.pdfbox.pdmodel.interactive.form.TestFields;
 import org.apache.pdfbox.util.TestDateUtil;
-import org.apache.pdfbox.util.TestImageIOUtils;
 import org.apache.pdfbox.util.TestMatrix;
 
 /**
@@ -97,7 +96,6 @@ public class TestAll extends TestCase
 
         suite.addTestSuite( TestIOUtils.class );
         suite.addTestSuite( TestRandomAccessBuffer.class );
-        suite.addTestSuite( TestImageIOUtils.class );
         suite.addTestSuite( TestPackedBitArray.class );
         suite.addTestSuite( TestCCITTFaxG31DDecodeInputStream.class );
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImageTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImageTest.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImageTest.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/PDInlineImageTest.java
Thu Oct  9 00:16:27 2014
@@ -31,7 +31,6 @@ import org.apache.pdfbox.pdmodel.PDDocum
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.pdfbox.util.ImageIOUtil;
 
 /**
  * Unit tests for PDInlineImage
@@ -114,7 +113,7 @@ public class PDInlineImageTest extends T
         assertEquals(height, image2.getHeight());
 
         // write and read
-        boolean writeOk = ImageIOUtil.writeImage(image1, "png", 
+        boolean writeOk = ImageIO.write(image1, "png",
                 new FileOutputStream(new File(testResultsDir + "/inline-grid1.png")));
         assertTrue(writeOk);
         BufferedImage bim1 = ImageIO.read(new File(testResultsDir + "/inline-grid1.png"));
@@ -122,7 +121,7 @@ public class PDInlineImageTest extends T
         assertEquals(width, bim1.getWidth());
         assertEquals(height, bim1.getHeight());
         
-        writeOk = ImageIOUtil.writeImage(image2, "png", 
+        writeOk = ImageIO.write(image2, "png",
                 new FileOutputStream(new File(testResultsDir + "/inline-grid2.png")));
         assertTrue(writeOk);
         BufferedImage bim2 = ImageIO.read(new File(testResultsDir + "/inline-grid2.png"));

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/image/ValidateXImage.java
Thu Oct  9 00:16:27 2014
@@ -16,6 +16,7 @@
 package org.apache.pdfbox.pdmodel.graphics.image;
 
 import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
@@ -23,13 +24,15 @@ import java.util.Set;
 import static junit.framework.TestCase.assertEquals;
 import static junit.framework.TestCase.assertNotNull;
 import static junit.framework.TestCase.assertTrue;
+
+
+import javax.imageio.ImageIO;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.pdfbox.util.ImageIOUtil;
 
 /**
  * Helper class to do some validations for PDImageXObject.
@@ -58,11 +61,11 @@ public class ValidateXImage
         assertEquals(ximage.getWidth(), ximage.getImage().getWidth());
         assertEquals(ximage.getHeight(), ximage.getImage().getHeight());
 
-        boolean writeOk = ImageIOUtil.writeImage(ximage.getImage(),
-                format, new NullOutputStream());
+        boolean writeOk = ImageIO.write(ximage.getImage(),
+                format, new ByteArrayOutputStream());
         assertTrue(writeOk);
-        writeOk = ImageIOUtil.writeImage(ximage.getOpaqueImage(),
-                format, new NullOutputStream());
+        writeOk = ImageIO.write(ximage.getOpaqueImage(),
+                format, new ByteArrayOutputStream());
         assertTrue(writeOk);
     }
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestPDFToImage.java Thu Oct 
9 00:16:27 2014
@@ -236,7 +236,7 @@ public class TestPDFToImage extends Test
                 new File(fileName + ".rendererror").delete();
                 LOG.info("Writing: " + fileName);
                 new FileOutputStream(new File(fileName + ".writeerror")).close();
-                ImageIOUtil.writeImage(image, fileName, 96);
+                ImageIO.write(image, "PNG", new File(fileName));
                 new File(fileName + ".writeerror").delete();
             }
 

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractImages.java Thu Oct  9
00:16:27 2014
@@ -40,7 +40,7 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 import org.apache.pdfbox.pdmodel.graphics.image.TIFFInputStream;
-import org.apache.pdfbox.util.ImageIOUtil;
+import org.apache.pdfbox.tools.imageio.ImageIOUtil;
 import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine;
 
 /**

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFReader.java Thu Oct  9 00:16:27
2014
@@ -40,7 +40,7 @@ import org.apache.pdfbox.tools.gui.Reade
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
-import org.apache.pdfbox.util.ImageIOUtil;
+import org.apache.pdfbox.tools.imageio.ImageIOUtil;
 
 /**
  * An proof-of-concept application to read PDF documents, with very basic functionality.

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java?rev=1630259&r1=1630258&r2=1630259&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java Thu Oct  9 00:16:27
2014
@@ -32,7 +32,7 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.rendering.ImageType;
 import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.pdfbox.util.ImageIOUtil;
+import org.apache.pdfbox.tools.imageio.ImageIOUtil;
 
 /**
  * Convert a PDF document to an image.

Copied: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.java
(from r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ImageIOUtil.java)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.java?p2=pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ImageIOUtil.java&r1=1630256&r2=1630259&rev=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/ImageIOUtil.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/ImageIOUtil.java Thu
Oct  9 00:16:27 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pdfbox.util;
+package org.apache.pdfbox.tools.imageio;
 
 import java.awt.image.BufferedImage;
 import java.io.File;
@@ -34,7 +34,7 @@ import javax.imageio.metadata.IIOMetadat
 import javax.imageio.stream.ImageOutputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.pdfbox.util.MetaUtil.STANDARD_METADATA_FORMAT;
+import static org.apache.pdfbox.tools.imageio.MetaUtil.STANDARD_METADATA_FORMAT;
 import org.w3c.dom.NodeList;
 
 /**
@@ -291,7 +291,7 @@ public class ImageIOUtil
     // sets the DPI metadata
     private static void setDPI(IIOMetadata metadata, int dpi, String formatName)
     {
-        IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(STANDARD_METADATA_FORMAT);
+        IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(MetaUtil.STANDARD_METADATA_FORMAT);
 
         IIOMetadataNode dimension = getOrCreateChildNode(root, "Dimension");
 
@@ -312,7 +312,7 @@ public class ImageIOUtil
 
         try
         {
-            metadata.mergeTree(STANDARD_METADATA_FORMAT, root);
+            metadata.mergeTree(MetaUtil.STANDARD_METADATA_FORMAT, root);
         }
         catch (IIOInvalidTreeException e)
         {

Copied: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java (from
r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/JPEGUtil.java)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java?p2=pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/JPEGUtil.java&r1=1630256&r2=1630259&rev=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/JPEGUtil.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java Thu Oct
 9 00:16:27 2014
@@ -13,13 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pdfbox.util;
+package org.apache.pdfbox.tools.imageio;
 
 import javax.imageio.metadata.IIOInvalidTreeException;
 import javax.imageio.metadata.IIOMetadata;
 import javax.imageio.metadata.IIOMetadataNode;
-import static org.apache.pdfbox.util.MetaUtil.JPEG_NATIVE_FORMAT;
-import static org.apache.pdfbox.util.MetaUtil.debugLogMetadata;
+import static org.apache.pdfbox.tools.imageio.MetaUtil.JPEG_NATIVE_FORMAT;
+import static org.apache.pdfbox.tools.imageio.MetaUtil.debugLogMetadata;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
@@ -39,11 +39,11 @@ class JPEGUtil
      */
     static void updateMetadata(IIOMetadata metadata, int dpi) throws IIOInvalidTreeException
     {
-        debugLogMetadata(metadata, JPEG_NATIVE_FORMAT);
+        MetaUtil.debugLogMetadata(metadata, MetaUtil.JPEG_NATIVE_FORMAT);
 
         // https://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
         // http://docs.oracle.com/javase/6/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html
-        Element root = (Element) metadata.getAsTree(JPEG_NATIVE_FORMAT);
+        Element root = (Element) metadata.getAsTree(MetaUtil.JPEG_NATIVE_FORMAT);
         NodeList jvarNodeList = root.getElementsByTagName("JPEGvariety");
         Element jvarChild;
         if (jvarNodeList.getLength() == 0)
@@ -86,6 +86,6 @@ class JPEGUtil
         {
             jfifChild.setAttribute("thumbHeight", "0");
         }
-        metadata.setFromTree(JPEG_NATIVE_FORMAT, root); // mergeTree doesn't work for ARGB
+        metadata.setFromTree(MetaUtil.JPEG_NATIVE_FORMAT, root); // mergeTree doesn't work
for ARGB
     }
 }

Copied: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java (from
r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java?p2=pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java&r1=1630256&r2=1630259&rev=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/MetaUtil.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java Thu Oct
 9 00:16:27 2014
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.pdfbox.util;
+package org.apache.pdfbox.tools.imageio;
 
 import java.io.StringWriter;
 import javax.imageio.metadata.IIOMetadata;

Copied: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java (from
r1630256, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java?p2=pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java&r1=1630256&r2=1630259&rev=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/TIFFUtil.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java Thu Oct
 9 00:16:27 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pdfbox.util;
+package org.apache.pdfbox.tools.imageio;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -24,8 +24,8 @@ 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;
+import static org.apache.pdfbox.tools.imageio.MetaUtil.SUN_TIFF_FORMAT;
+import static org.apache.pdfbox.tools.imageio.MetaUtil.debugLogMetadata;
 
 /**
  * Used by ImageIOUtil to write TIFF files.

Copied: pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/TestImageIOUtils.java (from
r1630256, pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java)
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/TestImageIOUtils.java?p2=pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/TestImageIOUtils.java&p1=pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java&r1=1630256&r2=1630259&rev=1630259&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/util/TestImageIOUtils.java (original)
+++ pdfbox/trunk/tools/src/test/java/org/apache/pdfbox/tools/TestImageIOUtils.java Thu Oct
 9 00:16:27 2014
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pdfbox.util;
+package org.apache.pdfbox.tools;
 
 import java.awt.Color;
 import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -35,9 +36,6 @@ import javax.imageio.metadata.IIOMetadat
 import javax.imageio.stream.ImageInputStream;
 
 import junit.framework.TestCase;
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,11 +44,10 @@ import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.graphics.PDXObject;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.NullOutputStream;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.pdfbox.rendering.ImageType;
 import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.pdfbox.util.ImageIOUtil;
+import org.apache.pdfbox.tools.imageio.ImageIOUtil;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -91,7 +88,8 @@ public class TestImageIOUtils extends Te
                         {
                             suffix = "JPEG2000";
                         }
-                        boolean writeOK = ImageIOUtil.writeImage(imageObject.getImage(),
suffix, new NullOutputStream());
+                        boolean writeOK = ImageIOUtil.writeImage(imageObject.getImage(),
suffix,
+                                new ByteArrayOutputStream());
                         assertTrue(writeOK);
                     }
                 }
@@ -117,7 +115,7 @@ public class TestImageIOUtils extends Te
         LOG.info("Preparing to convert " + file.getName());
         try
         {
-            float dpi = 120;
+            float dpi = 36; // low DPI so that rendering is FAST
             document = PDDocument.load(file);
 
             // Save image resources of first page



Mime
View raw message