You may know other package managers commands, but I only use these.
## An example
### By filesize
The files taken from the snapshot tool on my macbook.
~~~plain
33K 00_locales.png
61K 01_control-software.png
157K 02_mmdvmhost.png
184K 03_general.png
187K 04_dmrconfig.png
69K 05_exp_mmdvmhost-dmrnetwork.png
212K 06_exp_dmrgw-dmrnetwork1.png
236K 07_exp_dmrgw-dmrnetwork2.png
~~~
Three to four minutes later (all three commands):
~~~plain
17K 00_locales.png
33K 01_control-software.png
81K 02_mmdvmhost.png
98K 03_general.png
97K 04_dmrconfig.png
32K 05_exp_mmdvmhost-dmrnetwork.png
127K 06_exp_dmrgw-dmrnetwork1.png
144K 07_exp_dmrgw-dmrnetwork2.png
~~~
### By view
~~~plain
25K opti_01.png
13K opti_02.png
~~~
![Original image](opti_01.png "This is the unmodified image: `opti_01.png`") ![Optimized image](opti_02.png "And this is the optimized image: `opti_02.png`")
Do you see much difference?
## Using this with the **fish** shell
I added this to my fishs configuration (when I used fish for a while).
~~~fish
# file: "~/.config/fish/functions/opti.fish"
function opti --description "Optimizes .png files"
# Author: Dominic, OE7DRT <dominic@oe7drt.com>
# 2021-04-17
set -e missing
for program in optipng advpng pngcrush
if \! command -v $program > /dev/null
set -a missing $program
continue
end
end
if test -n "$missing"
echo "Could not find executables: $missing"
return 1
end
if test -z $argv[1]
echo "usage: opti <files...>"
return 1
end
set count (count $argv)
for i in (seq 1 $count)
if test ! -f $argv[$i]
echo "Could not read file $argv[$i]..."
continue
end
optipng -nb -nc "$argv[$i]";
advpng -z4 "$argv[$i]";
pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow "$argv[$i]";
end
end
~~~
And I made one for the jpeg version too:
~~~fish
# file: "~/.config/fish/functions/jopti.fish"
function jopti --description "Optimizes .jpg files"