Page 1 of 1

Overlaying an Image over a white background only

Posted: 2009-09-28T00:26:40-07:00
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

Re: Overlaying an Image over a white background only

Posted: 2009-09-28T19:52:40-07:00
by fmw42