Last active
August 29, 2015 14:11
-
-
Save renanyoy/1749c8c59f54678399bf to your computer and use it in GitHub Desktop.
convert all png to jpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function png2jpeg() { | |
echo 'Warning this command wil convert all png in jpeg recursively and delete png files' | |
echo "Do you wish to Continue?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) | |
for f in `find . -name "*.png"` | |
do | |
alpha=$(identify -format %A $f) | |
if [ "$alpha" == 'False' ] | |
then | |
convert $f ${f/.png/.jpg} | |
rm $f | |
echo "$f converted" | |
else | |
al=$(identify -verbose $f | grep -A 2 Alpha | grep min | grep 255) | |
if [ "${#al}" != '0' ] | |
then | |
convert $f ${f/.png/.jpg} | |
rm $f | |
echo "$f converted" | |
fi | |
fi | |
done | |
break;; | |
No ) | |
exit;; | |
esac | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment