Overlaying an Image over a white background only

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
bent
Posts: 2
Joined: 2009-08-06T00:57:22-07:00
Authentication code: 8675309

Overlaying an Image over a white background only

Post by bent »

Hello
Is it possible overlaying an image over the white region of another image?

Suppose I have two images: large.pnm (500x70px) and copyright.png (16x8px)

The first large image contains only text: so it has only two colors (black for the text & white for background).
I would overlap copyright.png over a white part of large.pnm.
So I have to determinate (and locate) 16x8px of white part in large.pnm...

Is it possible to do using a single comman line? How to do?

I have found this pseudo solution to check white regions, but it is too elaborate and require several system calls.

Code: Select all

exec("convert large.pnm -crop 16x8+0+0 TXT:out.txt");
exec("convert large.pnm -crop 16x8+16+0 TXT:out.txt");
exec("convert large.pnm -crop 16x8+32+0 TXT:out.txt");
... etc ... 
exec("convert large.pnm -crop 16x8+32+8 TXT:out.txt");
exec("convert large.pnm -crop 16x8+32+16 TXT:out.txt");
... etc
Got anything more simple?

Thank you so much for replies
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Overlaying an Image over a white background only

Post by fmw42 »

Post Reply