Skip to content

Instantly share code, notes, and snippets.

@jcward
Created January 4, 2017 21:32
Show Gist options
  • Select an option

  • Save jcward/cd16b781a2752332bd52e123fb9669d4 to your computer and use it in GitHub Desktop.

Select an option

Save jcward/cd16b781a2752332bd52e123fb9669d4 to your computer and use it in GitHub Desktop.
Shell script to take errant ImageMagick 6.7 alpha extract into account
# Create alpha mask
convert /tmp/image.png -alpha extract /tmp/alpha.png
# In ImageMagick version 6.7, there was an error with how this alpha channel output. But we
# actually tuned it with that error taken into account. So if you're using a later version
# then we actually want to make the alpha channel darker to look like 6.7 again.
im_version=`convert -version`
if [[ "$im_version" == *"ImageMagick 6.7"* ]]
then
echo "ImageMagick 6.7, no gamma adjustment required!"
else
echo "ImageMagick > 6.7, applying gamma adjustment to alpha channel"
convert /tmp/alpha.png -gamma 0.4472 /tmp/alpha.png
fi
# See: http://stackoverflow.com/questions/41468532/imagemagick-alpha-channel-extract-different-results-darker-on-6-7-vs-6-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment