Skip to content

Instantly share code, notes, and snippets.

@moalex
Created January 15, 2022 10:27
Show Gist options
  • Save moalex/9e606a0140295766ec98a467b848b1b6 to your computer and use it in GitHub Desktop.
Save moalex/9e606a0140295766ec98a467b848b1b6 to your computer and use it in GitHub Desktop.

ImageMagic Color Invert

ImageMagick 6

Can invert color intensities with -negate option only)

-negate

convert input.png -negate output.png

ImageMagick 7

Requires the -channel option with -negate)

Changed Options

convert input.png -channel RGB -negate output.png

This is because the default active channels contain transparency_(opaque/alpha)_ in ImageMagick 7.x

ImageMagick6: DefaultChannels = ((AllChannels | SyncChannels) &~ OpacityChannel)
ImageMagick7: DefaultChannels = AllChannels

Most algorithms update the red, green, blue, black (for CMYK), and alpha channels. Usability of -negate seems to be sacrificed for overall consistency.


More detail for you

source

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