Skip to content

Instantly share code, notes, and snippets.

@JasonMillward
Last active August 29, 2015 14:14
Show Gist options
  • Save JasonMillward/db35ccb0820d0e61f196 to your computer and use it in GitHub Desktop.
Save JasonMillward/db35ccb0820d0e61f196 to your computer and use it in GitHub Desktop.
#!/bin/bash
find . -type f -iname "*.png" -print0 | while IFS= read -r -d $'\0' file; do
isWhite=`convert $file -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:`
if [ "$isWhite" == "0" ]
then
rm $file
else
convert $file -bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 10% \
-fill none -floodfill +0+0 white \
-shave 1x1 $file
convert $file -channel rgba -alpha set -fuzz 10% -fill none -opaque white $file
fi
done
@vencax
Copy link

vencax commented Apr 18, 2015

Hi, I have made a little change, maybe you will like it: https://gist.github.com/vencax/5db701818b7132824f50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment