Skip to content

How to shave off a fixed number of pixels from a PNG with a transparent background using ImageMagick #7234

Answered by snibgo
Zaggo34 asked this question in Help
Discussion options

You must be logged in to vote

This doesn't make transparent all of the white-ish pixels.

magick ^
  twoStarsB.png ^
  ( +clone ^
    -alpha extract ^
    -threshold 50%% ^
    -write mpr:ALP ^
    -morphology EdgeIn Disk:2 ^
    -negate ^
    mpr:ALP ^
    -compose Darken -composite ^
  ) ^
  -alpha off ^
  -compose CopyOpacity -composite ^
  out.png

This is Windows BAT syntax. For bash, change every line-end caret ^ to backslash \, and escape the parentheses ( and ), and don't double the %%.

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@Zaggo34
Comment options

Comment options

You must be logged in to vote
1 reply
@Zaggo34
Comment options

Comment options

You must be logged in to vote
1 reply
@Zaggo34
Comment options

Answer selected by Zaggo34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants