Skip to content

Instantly share code, notes, and snippets.

@renanyoy
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renanyoy/1749c8c59f54678399bf to your computer and use it in GitHub Desktop.
Save renanyoy/1749c8c59f54678399bf to your computer and use it in GitHub Desktop.
convert all png to jpeg
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