Skip to content

Commit

Permalink
20141223
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jan 20, 2019
0 parents commit 378b862
Show file tree
Hide file tree
Showing 31 changed files with 1,245 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OptImgSH v2.6

OptImgSH - a set of scripts to optimize images.


optimg.sh - optimizing images (jpg | gif | png) without losing quality.
link [bash-optimg]

jpegmin.sh - optimizing images (jpg) with a loss of quality.
link [bash-jpegmin]

---
Made in Russia.

-- Stargazer --
I listen to the radio Wild - [http://www.radio-tochka.com:4570/]
20 changes: 20 additions & 0 deletions config/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Package: bash-optimg
Version: 20141223
Architecture: all
Maintainer: zvezdochiot <[email protected]>
Section: utils
Priority: optional
Installed-Size: 64
Depends: imagemagick, libjpeg-progs, gifsicle, pngcrush, optipng, advancecomp, pngnq, bc, coreutils
Homepage: http://mykaralw.narod.ru/
Description: Bash-script for optimize images.
Bash-script for optimize images:
optimizing images (jpg | gif | png) without losing quality:
bash-optimg image.[png|gif|jpg|jpeg]
bash-optimg-all
optimizing images (jpg | gif | fast png) without losing quality:
bash-optimg-fast image.[png|gif|jpg|jpeg]
bash-optimg-fast-all
optimizing images (jpg | gif | fast png 256 color) without losing quality:
bash-optimg-256 image.[png|gif|jpg|jpeg]
bash-optimg-256-all
14 changes: 14 additions & 0 deletions config/md5sums
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
b30007897e2dae7ef96cef4d6674f295 usr/share/doc/bash-optimg/depends
59e9e74486d8642e6baeafbc0dcaef16 usr/share/doc/bash-optimg/README.EN
fedc59b51e7ac958c9bfbc647a611b84 usr/share/doc/bash-optimg/README.RU
2a1cb2c4c1c62a22029f3e978d5e7004 usr/share/doc/bash-optimg/usage
effc52748f7c227858de3f030c6c04fb usr/share/man/man1/bash-optimg.1.gz
8aa76043b4bf8b61907a90be72f94000 usr/share/scripts/bash/optimg256all.sh
076df68b36da076c72a240f5052059d7 usr/share/scripts/bash/optimg.sh
81fc09bcd16b212c71b6f3fa1c66c09a usr/share/scripts/bash/optimgall.sh
29a77ab3ac31e7b3d7de7bf08af67439 usr/share/scripts/bash/optimgjpeg.sh
3ca4b6bc3069f9ed9b68114d49c22ec3 usr/share/scripts/bash/optimggif.sh
3e9004247e7b67a867b2f6b03c33b77d usr/share/scripts/bash/optimgfastall.sh
1a463542f6bc09b377b30e5b005bbb63 usr/share/scripts/bash/optimgpng.sh
c4f44f56c85d2ba1c6a7ea06882894bd usr/share/scripts/bash/optimgfast.sh
bd781715a7b885160813676818f44f7d usr/share/scripts/bash/optimg256.sh
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-256
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-256-all
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-all
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-fast
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-fast-all
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-gif
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-jpeg
1 change: 1 addition & 0 deletions data/usr/bin/bash-optimg-png
16 changes: 16 additions & 0 deletions data/usr/share/doc/bash-optimg/README.EN
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OptImgSH v2.6

OptImgSH - a set of scripts to optimize images.


optimg.sh - optimizing images (jpg | gif | png) without losing quality.
link [bash-optimg]

jpegmin.sh - optimizing images (jpg) with a loss of quality.
link [bash-jpegmin]

---
Made in Russia.

-- Stargazer --
I listen to the radio Wild - [http://www.radio-tochka.com:4570/]
15 changes: 15 additions & 0 deletions data/usr/share/doc/bash-optimg/README.RU
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
OptImgSH v2.6

OptImgSH - комплект скриптов для оптимизации изображений.


optimg.sh - оптимизация изображений (jpg|gif|png) без потери качества.
link [bash-optimg]

jpegmin.sh - оптимизация изображений (jpg) с потерей качества.
link [bash-jpegmin]
--
Сделано в России.

-- звездочет --
Я слушаю Дикое радио - [http://www.radio-tochka.com:4570/]
13 changes: 13 additions & 0 deletions data/usr/share/doc/bash-optimg/depends
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#optimg.sh
#depends:

imagemagick
libjpeg-progs
gifsicle
pngnq
pngcrush
optipng
advancecomp
coreutils

#end
17 changes: 17 additions & 0 deletions data/usr/share/doc/bash-optimg/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Bash-script for optimize images:
optimizing images (jpg | gif | png) without losing quality:

$ bash-optimg image.[png|gif|jpg|jpeg]
$ bash-optimg-all

optimizing images (jpg | gif | fast png) without losing quality:

$ bash-optimg-fast image.[png|gif|jpg|jpeg]
$ bash-optimg-fast-all

optimizing images (jpg | gif | fast png 256 color) without losing quality:

$ bash-optimg-256 image.[png|gif|jpg|jpeg]
$ bash-optimg-256-all

# Made in Russia.
1 change: 1 addition & 0 deletions data/usr/share/man/man1/bash-optimg-256-all.1.gz
1 change: 1 addition & 0 deletions data/usr/share/man/man1/bash-optimg-256.1.gz
1 change: 1 addition & 0 deletions data/usr/share/man/man1/bash-optimg-all.1.gz
1 change: 1 addition & 0 deletions data/usr/share/man/man1/bash-optimg-fast-all.1.gz
1 change: 1 addition & 0 deletions data/usr/share/man/man1/bash-optimg-fast.1.gz
Binary file added data/usr/share/man/man1/bash-optimg.1.gz
Binary file not shown.
167 changes: 167 additions & 0 deletions data/usr/share/scripts/bash/optimg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/bash

VER="20140329"
GREEN="\033[1;32m"
RED="\033[0;31m"
YELLOW="\033[1;33m"
ENDCOLOR="\033[0m"

RAMDISK="/dev/shm"

tproc=`basename $0`
echo -e $GREEN"$tproc version $VER"$ENDCOLOR
echo ""

usage()
{
tproc=`basename $0`
echo -e $YELLOW"usage:"$ENDCOLOR
echo -e $GREEN" bash $tproc img-before.[jpg|gif|png] "$ENDCOLOR
exit 0
}

testargs()
{
if [ "+$1" = "+" -o "+$1" = "+--help" -o "+$1" = "+-h" ]
then
usage
fi
}

testcomponent()
{
tnocomp=""
tcomp="/usr/bin/identify"
tdeb="imagemagick_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/jpegtran"
tdeb="libjpeg-progs_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/gifsicle"
tdeb="gifsicle_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/pngcrush"
tdeb="pngcrush_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/optipng"
tdeb="optipng_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/advpng"
tdeb="advancecomp_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
tcomp="/usr/bin/stat"
tdeb="coreutils_*.deb"
if [ ! -f "$tcomp" ]
then
tnocomp="$tnocomp $tcomp($tdeb)"
fi
if [ "+$tnocomp" != "+" ]
then
echo -e $RED"Not found $tnocomp !"$ENDCOLOR
echo ""
exit 0
fi
}

testsource()
{
src="$1"
if [ ! -f "$src" ]
then
echo "File $src does not exist"
usage
fi
}

main()
{
tproc=`basename $0`
src="$1"

if [ -d "$RAMDISK" ]
then
tmppath="$RAMDISK"
else
tmppath="/tmp"
fi
TYPE=`identify "$src" | grep -E -o 'JPEG|GIF|PNG'`
OLD=`stat -c %s "$src"`

echo "$src: $OLD"
case "$TYPE" in
JPEG)
tmpjp="$tmppath/optimg.p.$$.jpg"
tmpjn="$tmppath/optimg.n.$$.jpg"
jpegtran -copy none -optimize -perfect -progressive -outfile "$tmpjp" "$src"
jpegtran -copy none -optimize -perfect -outfile "$tmpjn" "$src"
if [ -f "$tmpjp" -a -f "$tmpjn" ]; then
S_PROG=`stat -c %s "$tmpjp"`
S_NORM=`stat -c %s "$tmpjn"`
echo " normal: $S_NORM"
echo " progressive: $S_PROG"
if [ $S_PROG -ge $S_NORM ]; then
mv -f "$tmpjn" "$src"
rm -f "$tmpjp"
else
mv -f "$tmpjp" "$src"
rm -f "$tmpjn"
fi;
fi
;;

GIF)
gifsicle -O2 -b "$src"
;;

PNG)
tmppng="$tmppath/optimg.$$.png"
pngcrush -q -rem alla -fix "$src" "$tmppng"
if [ ! -s "$tmppng" ]
then
cp "$src" "$tmppng"
fi
tsize=`stat -c %s "$tmppng"`
echo " pngcrush: $tsize"
optipng -zc6-9 -zm1-9 -zs0-3 -f0-5 -q -fix "$tmppng"
tsize=`stat -c %s "$tmppng"`
echo " optipng: $tsize"
advpng -z -4 -q "$tmppng"
tsize=`stat -c %s "$tmppng"`
echo " advpng: $tsize"
if [ -f "$tmppng" ]; then
mv -f "$tmppng" "$src"
fi;
;;
esac

NEW=`stat -c %s "$src"`
SDIFF=$(($NEW * 100 / $OLD))

echo "old size: $OLD, new size: $NEW ($SDIFF%)"
echo ""
}

testargs "$@"
testcomponent
testsource "$@"
main "$@"

#end
Loading

0 comments on commit 378b862

Please sign in to comment.