Page 1 of 1

combining several PNG8 into an image

Posted: 2015-11-21T08:13:42-07:00
by gaylorr
windows 7 Pro (x64) 6.9.2 Q8

I am tryin to (in a windows .CMD script) combine 5 images, all are PNG8 formatted from a previous process...

Each image is a single color of R, G or B...I want to bring all of them into a new image and combine them to get an image out that is the UNUSED pixels of this combine.

So basically additive to result in a NEW image, all white, where ever the other previous images are empty.

I have tried every combination I could think of to achieve this.
Thanks for your patience this week with all of my questions...lots of possibilities, and apparently I have not figured it out yet.

The reason for this is I have to create a total of 6 texture, all taking into account every pixel in my 4096x4096 space. The first 5 each represent some pixels as materials. The 6th (the one I am tryin to build now) is the left over pixels from the previous 5 textures. Therefore I have accounted for ALL of the pixels.

Thanks

Re: combining several PNG8 into an image

Posted: 2015-11-21T08:35:43-07:00
by snibgo
If I understand correctly, you have 5 images the same size. Each has some opaque pixels and some transparent. You want an output the same size, that is white where all of the five are transparent, and some other colour (black?) where any of them are opaque.

Code: Select all

convert in1.png in2.png in3.png in4.png in5.png -alpha extract -negate -compose Multiply -layers merge out.png
This replaces each image with one that is black where the pixel was transparent, or white where it was opaque. They are negated, then multipled. The result is black where any were opaque, otherwise white.

Re: combining several PNG8 into an image

Posted: 2015-11-21T08:55:30-07:00
by gaylorr
snibgo wrote:If I understand correctly, you have 5 images the same size. Each has some opaque pixels and some transparent. You want an output the same size, that is white where all of the five are transparent, and some other colour (black?) where any of them are opaque.

Code: Select all

convert in1.png in2.png in3.png in4.png in5.png -alpha extract -negate -compose Multiply -layers merge out.png
This replaces each image with one that is black where the pixel was transparent, or white where it was opaque. They are negated, then multipled. The result is black where any were opaque, otherwise white.
That is close...wow...Multiply...would not have thought of that...

The only other thing I need is it to be a PNG8...so that the none-used pixels are transparent. How do I get the "black" to become transparent?

Re: combining several PNG8 into an image

Posted: 2015-11-21T09:22:30-07:00
by snibgo
When you multiply a load of numbers together then if any of them is zero, the result is zero. I could have used "compose Darken".

To make black transparent, add "-transparent black" before the output filename. To make it PNG8, prefix the filename with that, eg "PNG8:out.png".

Re: combining several PNG8 into an image

Posted: 2015-11-21T09:29:13-07:00
by gaylorr
That worked! Thank you!

More and more I use this I understand more the sequence of operations...I have read all the "help" and "how to's" listed but until you do it more, it doesnt really make sense.

Thanks again!