author Rudolf Polzer Mon, 21 Jun 2010 13:09:03 +0000 (15:09 +0200) committer Rudolf Polzer Mon, 21 Jun 2010 13:09:03 +0000 (15:09 +0200)

index f9ba64a92215a935e890c8ef0168bc956ac8b58e..6c88ccbea21d4a16c1d6685faf36ee2dbc8e8528 100755 (executable)
@@ -3,19 +3,14 @@
set -e

: \${qual:=95}
+: \${qual_alpha:=99}

for X in "\$@"; do
case "\$X" in
*.jpg)
-                       if [ -n "\$scaledown" ]; then
-                               mogrify -geometry "\$scaledown" -quality 100 "\$X"
-                       fi
jpegoptim --strip-all -m\$qual "\$X"
;;
*.png|*.tga)
-                       if [ -n "\$scaledown" ]; then
-                               mogrify -geometry "\$scaledown" -quality 100 "\$X"
-                       fi
if convert "\$X" -depth 16 RGBA:- | perl -e 'while(read STDIN, \$_, 8) { substr(\$_, 6, 2) eq "\xFF\xFF" or exit 1; ++\$pix; } exit not \$pix;'; then
echo "\$X has no alpha, converting"
convert "\$X" -quality 100 "\${X%.*}.jpg"
@@ -25,7 +20,8 @@ for X in "\$@"; do
echo "\$X has alpha, converting twice"
convert "\$X" -alpha extract -quality 100 "\${X%.*}.jpg"
convert "\$X" -alpha off     -quality 100 "\${X%.*}_alpha.jpg"
-                               jpegoptim --strip-all -m\$qual "\${X%.*}_alpha.jpg"
+                               jpegoptim --strip-all -m\$qual "\${X%.*}.jpg"
+                               jpegoptim --strip-all -m\$qual_alpha "\${X%.*}_alpha.jpg"
rm -f "\$X"
fi
;;