IMAGE OVERLAPING AND COLORING

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
foruforewer
Posts: 26
Joined: 2011-02-08T04:37:21-07:00
Authentication code: 8675308

IMAGE OVERLAPING AND COLORING

Post by foruforewer »

HI

I have two images and desired output which are as below. For same i have written below code. But i am not able to
1) Get black ground behind fonts.
2) Change image color
3) Common overlapped area changes color, while i want simply overlapped.

Can anyone guide?

Code: Select all

set in_path=C:\
set ou_path=C:\
set suffix=T.png

convert %in_path%%~1%suffix% -level 100%,0 im1.png
convert %in_path%%~2%suffix% -level 100%,0 im2.png

convert im1.png +level-colors red, +repage im1.png
convert im2.png +level-colors navy, +repage im2.png

composite -compose Multiply -gravity center im1.png im2.png %ou_path%%~3
convert %ou_path%%~3 -gravity north -splice 0X10 -gravity east -splice 10x0 -gravity west -splice 10x0 -gravity south -splice 0X60 -background black -pointsize 30 -font Arial-Bold -fill red -annotate -140+3 %~1 -fill navy -annotate +140+3 %~2 %ou_path%%~3

del im1.png
del im2.png

Source Image #1
Image

Source Image #2
Image

Desired Output#3
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IMAGE OVERLAPING AND COLORING

Post by fmw42 »

colorize the black lines as desired. make the white background transparent, then just use -background black -flatten for the two images. give that a try and see what happens.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: IMAGE OVERLAPING AND COLORING

Post by anthony »

The specific commands to use to make color overlays of the shapes is
-negate -backgound {color} -alpha shape

See Alpha Shape
http://www.imagemagick.org/Usage/masking/#alpha_shape

This ensures that white parts are made transparent, but the edges have there anti-aliasing pixel shades preserved.

You would then 'flatten' all the colored image shapes on a black (or other) background, a technique known as 'layering'
http://www.imagemagick.org/Usage/layers/#layers
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply