invert image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Nik
Posts: 37
Joined: 2009-09-16T03:54:58-07:00
Authentication code: 8675309

invert image

Post by Nik »

Hi there,

is there a way to invert an image similar to the Photoshop command?

I have used the below command to create a difference mask:

convert whitebackground.JPG blackbackground.JPG -compose difference -composite \
-separate -background black -compose plus -flatten \
difference_plus.gif

The image that is produced looks to be a good mask to remove the background from and image. The only problem is that the areas of the difference_plus.gif that are white I want to be black and vice versa. When I invert the image in Photoshop I can then use it to remove the background from the white.JPG using this command:

convert whitebackground.JPG difference_plus.gif \
-alpha off -compose CopyOpacity -composite \
overlay_removed.png

Many Thanks,
Nik
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: invert image

Post by Bonzo »

Try -negate
Nik
Posts: 37
Joined: 2009-09-16T03:54:58-07:00
Authentication code: 8675309

Re: invert image

Post by Nik »

Perfect!!!!

Thanks Bonzo,

Nik
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: invert image

Post by anthony »

IM Examples, Color Modifications (global), Negate
http://www.imagemagick.org/Usage/color_mods/#negate
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply