I am using imageOptim to optimize images on my server.
It took me quite some time to learn rudimentary bash scripting to able to optimize all images in all my first level directories. My script looks as below and from functional point of view it does exactly what I want:
for dir in mydir/*/
do
sudo jpegoptim --strip-all -t "$dir"*.jpg
done
The problem is aesthetic. When I run the script it outputs the following:
mydir/dir_1/img_1.jpg axb 24bit N JFIF [OK] 2234 --> 1861 bytes (16.70%), optimized.
...
mydir/dir_1/img_16.jpg axb 24bit N JFIF [OK] 2234 --> 1861 bytes (16.70%), optimized.
Average compression (16 files): 7.26% (8k)
mydir/dir_2/img_1.jpg axb 24bit N JFIF [OK] 2234 --> 1861 bytes (16.70%), optimized.
...
mydir/dir_2/img_6.jpg axb 24bit N JFIF [OK] 2234 --> 1861 bytes (16.70%), optimized.
Average compression (6 files): 7.26% (8k)
It outputs the line Average compression (6 files): 7.26% (8k)
because I asked for a summary with the -t
flag. But I do not want to get all information about each individual image. When I try to suppress it with -t -q
or -tq
or -q -t
(I tried them all because I am not sure it it matters) it showed no information at all.
Ideally I just want to see one number - how much size have I saved.
Because this is my first bash script (I struggled for an hour with that loop :-( ), my skills currently are not sufficient to solve my problem.