How to add 2 same size images together and convert to black

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
PandoraBox
Posts: 23
Joined: 2011-04-10T14:08:11-07:00
Authentication code: 8675308

How to add 2 same size images together and convert to black

Post by PandoraBox »

What's the best way to merge 2 images that are mostly white but with only one color (that is not specific) and adding a second image that has a different color on top of it replacing the white parts and not touching the other colors (None of theses pixels will ever overlap so there is no issue there) I know it's the compose formula but I have no idea what would be the best one for this type of job as the white is not transparent (or does it really matter?)

Reason for this is that I might of figured out a way for people who want the inkscape trace option but without the inkscape interface.

Only other part I'll find on the imagemagick site is the amount of each color to make the layers from least to most in the svg file but I think convert image -format %c histogram:info:- will do just fine for the job.
Edit just tested the histogram this one convert input.jpg -format %c histogram:info:out.txt works better but is there a way to sort the colors from smallest to largest sum?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add 2 same size images together and convert to black

Post by snibgo »

You could make white pixels transparent in one image, and composite that over the other.

Code: Select all

convert inA.png ( inB.png -transparent White ) -composite out.png
snibgo's IM pages: im.snibgo.com
Post Reply