Skip to content

Commit

Permalink
Updated SAMBox. Use new method in SAMBox to check for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
torakiki committed May 8, 2016
1 parent 760a9a7 commit d4636dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<jdepend.version>2.9.1</jdepend.version>
<hibernate-validator.version>4.2.0.Final</hibernate-validator.version>
<hamcrest.version>1.3</hamcrest.version>
<sambox.version>1.0.0.RELEASE</sambox.version>
<sambox.version>1.0.1.RELEASE</sambox.version>
<xmlgraphics.version>2.1</xmlgraphics.version>
<bouncycastle.version>1.54</bouncycastle.version>
<!-- so that build is not platform dependent via encoding -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.sejda.sambox.contentstream.operator.state.Save;
import org.sejda.sambox.contentstream.operator.state.SetGraphicsStateParameters;
import org.sejda.sambox.contentstream.operator.state.SetMatrix;
import org.sejda.sambox.cos.COSArray;
import org.sejda.sambox.cos.COSBase;
import org.sejda.sambox.cos.COSDictionary;
import org.sejda.sambox.cos.COSName;
Expand Down Expand Up @@ -115,7 +114,7 @@ public void process(Operator operator, List<COSBase> operands) throws IOExceptio
removeAlternatesIfNeeded(stream);

if (parameters.getOptimizations().contains(Optimization.COMPRESS_IMAGES)) {
boolean jbig2Image = isJbig2Image(stream);
boolean jbig2Image = stream.hasFilter(COSName.JBIG2_DECODE);
if(jbig2Image) {
LOG.debug("Skipping JBIG2 encoded image");
}
Expand Down Expand Up @@ -152,17 +151,6 @@ public void process(Operator operator, List<COSBase> operands) throws IOExceptio
}
}

private boolean isJbig2Image(COSStream image) {
COSBase filters = image.getFilters();
if (filters instanceof COSName) {
return COSName.JBIG2_DECODE.equals(filters);
}
if (filters instanceof COSArray) {
return ((COSArray) filters).contains(COSName.JBIG2_DECODE);
}
return false;
}

private void optimize(COSName objectName, PDImageXObject image, IndirectCOSObjectIdentifier id, int displayWidth, int displayHeight) {
try {
LOG.debug("Optimizing image {} {} with dimensions {}x{}", objectName.getName(), id.toString(), image.getImage().getWidth(), image.getImage().getHeight());
Expand Down

0 comments on commit d4636dc

Please sign in to comment.