Created
October 29, 2011 22:43
-
-
Save bortels/1325189 to your computer and use it in GitHub Desktop.
Use ImageMagick to convert PNG background to transparent alpha
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
#!/usr/bin/perl | |
$img = shift @ARGV; | |
$corner = `convert $img -format '%[pixel:s.p{0,0}]' info:`; | |
chomp $corner; | |
print "corner color is $corner\n"; | |
@r = split(/\./, $img); | |
$ext = pop @r; | |
$name = join('.', @r); $name = $name . "_new." . $ext; | |
print "Saving to $name\n"; | |
system("convert $img -alpha set -channel RGBA -fuzz 1% -fill none -floodfill +0+0 $corner $name"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment