pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1836424 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Date Sun, 22 Jul 2018 08:03:26 GMT
Author: tilman
Date: Sun Jul 22 08:03:26 2018
New Revision: 1836424

URL: http://svn.apache.org/viewvc?rev=1836424&view=rev
Log:
PDFBOX-4184: compare sizes of different strategies for small non 16 bit images

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1836424&r1=1836423&r2=1836424&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Sun Jul 22 08:03:26 2018
@@ -83,6 +83,22 @@ public final class LosslessFactory
                 PDImageXObject pdImageXObject = new PredictorEncoder(document, image).encode();
                 if (pdImageXObject != null)
                 {
+                    if (pdImageXObject.getBitsPerComponent() < 16 &&
+                        image.getWidth() * image.getHeight() <= 50 * 50)
+                    {
+                        // also create classic compressed image, compare sizes
+                        PDImageXObject pdImageXObjectClassic = createFromRGBImage(image,
document);
+                        if (pdImageXObjectClassic.getCOSObject().getLength() < 
+                            pdImageXObject.getCOSObject().getLength())
+                        {
+                            pdImageXObject.getCOSObject().close();
+                            return pdImageXObjectClassic;
+                        }
+                        else
+                        {
+                            pdImageXObjectClassic.getCOSObject().close();
+                        }
+                    }
                     return pdImageXObject;
                 }
             }



Mime
View raw message