I got a phpbb forum which has about 40 gb of images and I would like to strip them down all of them. The main problem is that all images are located in a folder where images doesn't have extensions and they are jpeg's, png's, and gif's.
I installed already optipng, jpegtran, pngquant, pngcrush, imagick and other but I cannot optimize the files in batch because it says that filename is invalid.
The script which I am using and is working flawless for any other "normal" images with extensions is this:
#!/bin/sh
# pngcrush
for png in `find . | grep .png`; do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
# preserve original on error
if [ $? = 0 ]; then
mv -f temp.png $png
else
rm temp.png
fi
done
# jpegtran
for jpg in `find . | grep .jpg`; do
echo "crushing $jpg ..."
jpegtran -copy none -optimize -perfect "$jpg" > temp.jpg
# preserve original on error
if [ $? = 0 ]; then
mv -f temp.jpg $jpg
else
rm temp.jpg
fi
done
Example of images:
10028_0a41aaddab65adcbcdcce682bc733dae 14206_159fab7918af92e498d9616a65852246
As I told you before I do not know if this images are jpeg's or png's; the image in this example have 22 mb and 16 mb, respectively.
I am looking forward to hearing from you.