summaryrefslogtreecommitdiff
path: root/test_comp.sh
diff options
context:
space:
mode:
authorJohannes Schauer <josch@debian.org>2016-08-16 16:35:49 +0200
committerJohannes Schauer <josch@debian.org>2016-08-16 16:35:49 +0200
commit65960d846bed2bbc1a83269b715bb78e83e36478 (patch)
tree49728d11d3f9269ad1856c1eaaf32b6a4a933028 /test_comp.sh
Import img2pdf_0.2.1.orig.tar.gz
[dgit import orig img2pdf_0.2.1.orig.tar.gz]
Diffstat (limited to 'test_comp.sh')
-rwxr-xr-xtest_comp.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/test_comp.sh b/test_comp.sh
new file mode 100755
index 0000000..ae832e2
--- /dev/null
+++ b/test_comp.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+if [ $# -ne 1 ]; then
+ echo "usage: $0 image"
+ exit
+fi
+
+echo "converting image to pdf, trying all compressions imagemagick has to offer"
+echo "if, as a result, Zip/FlateDecode should NOT be the lossless compression with the lowest size ratio, contact me j [dot] schauer [at] email [dot] de"
+echo "also, send me the image in question"
+echo
+
+imsize=`stat -c "%s" "$1"`
+
+for a in `convert -list compress`; do
+ echo "encode:\t$a"
+ convert "$1" -compress $a "`basename $1 .jpg`.pdf"
+ pdfimages "`basename $1 .jpg`.pdf" "`basename $1 .jpg`"
+ /bin/echo -ne "diff:\t"
+ diff=`compare -metric AE "$1" "\`basename $1 .jpg\`-000.ppm" null: 2>&1`
+ if [ "$diff" != "0" ]; then
+ echo "lossy"
+ else
+ echo "lossless"
+ fi
+ /bin/echo -ne "size:\t"
+ pdfsize=`stat -c "%s" "\`basename $1 .jpg\`.pdf"`
+ echo "scale=1;$pdfsize/$imsize" | bc
+ /bin/echo -ne "pdf:\t"
+ grep --max-count=1 --text /Filter "`basename $1 .jpg`.pdf"
+ echo
+done