Page 1 of 1

Generate checkerboard superposition of two images

Posted: 2017-04-12T00:29:35-07:00
by ChrCoello
I would like to find a command that allows to combine two images (A.png and B.png) and generate a checkerboard superposition of the two (like you can see below https://i.stack.imgur.com/1kYTP.png).
Image
Image A.png and B.png are 64x64. The content of these images can be completly different. The output image C.png should be composed of : top row first left tile: image A 8x8, top row second tile: image B 8x8, top row third tile image A 8x8, etc...

I have searched ImageMagick compose and convert quite a bit now without success. If anybody has any tip, that would be fantastic.

Thanks in advance, Chris.

Re: Generate checkerboard superposition of two images

Posted: 2017-04-12T07:02:59-07:00
by GeeMack
ChrCoello wrote: 2017-04-12T00:29:35-07:00I would like to find a command that allows to combine two images (A.png and B.png) and generate a checkerboard superposition of the two...
It is always more helpful if you provide the version of ImageMagick you're using and let us know what platform or OS you're working on. (It's one of the rules described in THIS post at the top of the forum.) The exact commands and syntax may be very different from one version/OS/etc. to another. That said...

There are several ways to approach this. If your two input images are the same dimensions and orientation, you can create exactly the effect you describe using a command like this with IM6 from a Windows command line...

Code: Select all

convert input1.png input2.png -set option:distort:viewport "%[w]x%[h]" -filter point ^
   ( pattern:gray50 -scale 800% -virtual-pixel tile -distort SRT 0 ) -composite output.png
If you're using IM7, start the command with "magick" instead of "convert". If you're running it from a Windows BAT script you'll need to change all the single percent signs "%" to doubles "%%". If you're running it on a *nix shell or script you'll need to change the continued line caret "^" to a backslash "\" and escape the parentheses with backslashes "\( ... \)", and it may require other tweaks.

Re: Generate checkerboard superposition of two images

Posted: 2017-04-12T09:41:53-07:00
by fmw42
If on Unix-like system, you can try my script, interweave, at my link below. It is based on code similar to that of GeeMack above. But his is more concise.

Re: Generate checkerboard superposition of two images

Posted: 2017-04-19T14:21:27-07:00
by ChrCoello
@GeeMack yes sorry, should have said what OS (Ubuntu) and version (6.8.9-9) I am using. Thanks for your answers.
@fmw42 GREAT script, the interweave does exactly what I was looking for.

Very useful.

Christopher