Help needed creating layered contact sheet w/ alpha trans

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?".
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Help needed creating layered contact sheet w/ alpha trans

Post by ohai »

Wait!!! I know it's a long post... Don't leave! :)

I've got a folder structure with multiple levels of subfolders, each containing groups of images in sets of 6 or 8 or 10 or 12.. some have as many as 50.. almost all are 512x512 pixels.. some contain degrees of alpha transparency and some don't. I'm using IM on windows XP from a command shell.

What I'd like to do is create montage'd contact sheets for each folder, saved in each respective folder, that places the images in the most logical grid fashion, for example 6 images into a 3x2 grid, 8 images into a 4x2 or 3x3 grid, etc.. (using -geometry 110x110+9+9 seems to work well and gives me a 512x512 output image, but doesn't work when the grid is not 4x4 so I think I'm doing something wrong there.)

I'd like to be able to do my contact sheets montage'd over a custom-made grey-and-white checkerboard pattern so that those images which have alpha will show as having alpha (i.e. the checkerboard pattern will show through the alpha areas and maintain the specific degrees of alpha per pixel)... I'd like that checkerboard pattern to only display "within" the confines of each image tile stacked above it, and I would like the entire montage to sit over yet another custom image which will basically just act as a backdrop for the entire contact sheet.. some kind of subtle pattern or gradient perhaps.

So, basically, "My Images" sitting over "Checkerboard Pattern" sitting over "Lightly Textured Backdrop"

Lastly, I would like to force the entire montage'd group of images downward on the sheet, so that there's a built-in ~100px "Header" space at the top of the image wherein I can include a custom title or logo that would essentially be part of the bottom-most backdrop layer. I'm attaching an image here which attempts to illustrate what I want to accomplish, and here is the command line I've come up with so far..

Code: Select all

montage -background "transparent" -texture e:\Contact_Sheet_Backdrop.tga -depth 8 -type TrueColorMatte *.tga -geometry 110x110+9+9 -tile 4x3 -matte -transparent "transparent" -type TrueColorMatte -depth 8 ContactSheet.png
Image

It's still missing the alpha checkerboard inclusion between the thumbnails and the backdrop, and it's missing the "downward push" to create the margin/header space at the top. Also, the issue with forcing an output size of 512x512 regardless of grid size has been confusing me... Can anyone help with this?

(I read in another post that some users are creating batch files with their specific command structures and were then dropping the folder onto the batch file and having it process the folder and outputting the contact sheet into the folder.. something like that would be absolutely ideal but right now I'm more concerned with figuring out the exact structure of the command.)

Thanks in advance for any help you can provide.. getting this set up with a deadline looming is giving me a headache :)

-ohai
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

you will have to create your label (see label: for example at http://www.imagemagick.org/Usage/annotating/#anno_below) and append to your image.

to create a checkerboard, use -size WIDTHxHEIGHT pattern:checkerboard -- see http://www.imagemagick.org/script/forma ... n-patterns

I am a Mac/Unix person, so you will need some help from one of the Windows users to put it together as a drag and drop batch file.

You will likely have to do some command lines with convert and others with montage to get all the background images you want (transparent and checkerboard)
Last edited by fmw42 on 2010-05-17T16:24:55-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help needed creating layered contact sheet w/ alpha tran

Post by snibgo »

I'm confused. Your inputs are mostly 512x512, tiled to 4x2 or whatever, creating an output that is 512x512? Perhaps you want to shrink the output to fit into 512x512.

I suggest you start with simple commands and work your way up. Compose each input over your checkerboard (using mogrify, or looping with convert), then montage those on your backdrop, then extend the image with a top border. If you are an IM novice, you shouldn't start by trying to do it all in a single command. (Besides, it may not be possible.) Then make it drag-and-drop, which will involve looping through the commands, once per directory.
snibgo's IM pages: im.snibgo.com
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Re: Help needed creating layered contact sheet w/ alpha tran

Post by ohai »

snibgo wrote:I'm confused. Your inputs are mostly 512x512, tiled to 4x2 or whatever, creating an output that is 512x512? Perhaps you want to shrink the output to fit into 512x512.
Yes the images are mostly 512x512 and they need to be shrunk down in size to fit inside a 512x512 space. So here's what I need to do, in a nutshell:

1. Feed in a directory of 512x512 source images/photos/textures. Shrink them down in size and arrange them in a grid. If there are 6 images, a 3x2 grid. If there are 8 images, a 4x2 or 3x3, etc etc. If there are 10 images, a 4x3 grid. If there are 16 images, a 4x3 grid that spills over into a second sheet. And so on... If it's easier to use the exact same grid arrangement regardless of images that would be fine. So.. for example...

Image

2. Feed in a grey/white checkerboard texture (or auto-generate one?), scale it to the exact same size as the images/photos/textures from step 1, and arrange it in the exact same grid as step 1, placing them under the images in step 1 so that any alpha transparency channels in the step 1 images are easily recognizable as such because the grey/white checkerboard will now be seen "through" them.

Image

There are now effectively 2 "layers" of info.. the source images on top of the grey/white checkerboard.

3. Move both layers downward on the sheet to open a header area on top of the sheet.

Image

4. Feed in a final 512x512 "backdrop" or "wallpaper" image and place it under the 2 other layers, basically so it looks pretty instead of a plain white background.

Image

5, Output this entire composited image as a 512x512 contact sheet, containing a grid of thumbnails, or multiple sheets if there were too many source images to fit on a single page...

Image

So that's pretty much it... Later I can worry about overlaying a watermark/copyright alpha image and possibly adding dropshadow under the thumbnails, etc, but what I've diagrammed here is the core of what I need to accomplish...

-ohai
Last edited by ohai on 2010-05-17T18:50:02-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help needed creating layered contact sheet w/ alpha tran

Post by snibgo »

I can't see your example images. Instead, I get a graphic that says "Not cool. Hotlinking is theft!"

I think your scheme is over complicated. In step 2, how will you create the checkerboards the exact size and grid spacing as step 1? Possible, but very messy. Much simpler I think to composite each input over a checkerboard, and montage the results.

If you want a maximum of 12 images per sheet, your script will need to count the number of inputs and generate each sheet as appropriate. I suggest you ignore this aspect for now, and simply generate a single sheet.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

what grid arrangement are you going to use when the number of images is odd? are you going to pick an arrangement that leaves one image empty? for example 5 or 7 images (9 works out well as 3x3)?
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Re: Help needed creating layered contact sheet w/ alpha tran

Post by ohai »

I moved the images to photobucket instead. Sorry about that.

I've been reading through as much of the documentation as possible but I'm not quite sure which functions I should be using for all of this.. At first I thought 'montage' was all I needed but now it seems that something like 'composite -compose -tile pattern:checkerboard' is needed in there to create the checkerboard if it's not going to done from a premade external image.

On another note, I can't seem to find anything that will push the entire grid downward. -gravity doesn't look like it will work because it adds the same padding around every image, not just the top row, so that would create an equidistant spacing between each row and not push the full grid downward while maintaining the original spacing...
fmw42 wrote:what grid arrangement are you going to use when the number of images is odd? are you going to pick an arrangement that leaves one image empty? for example 5 or 7 images (9 works out well as 3x3)?
Yes, leaving 1 or 2 grid squares empty will be fine... so for example 10 images in a 4x3 will leave 2 slots empty.. that's fine...

-ohai
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

to make a checkerboard try

convert -size 100x100 pattern:checkerboard -auto-level checks.gif

I don't think you can do it within montage. So as I said before, you may need several steps.

To shift things down, you have to create a label image as I said above and then append it to your image. Or use -gravity to composite your montaged result onto a larger background.

Not sure if you want the result to be 512x512 including the label or if you want the montage to be 512x512 and then add extra space for the label at the top or bottom, so that the final image is larger than 512x512. Please clarify.

Also it does not look like montage supports transparent images.

tried this

montage logo2t.png logo2t.png logo2t.png logo2t.png -channel rgba -alpha on -geometry +10+10 -tile 2x2 tmp.png

but alpha channel was removed. The only way to keep the alpha channel is to add -background none as per

montage logo2t.png logo2t.png logo2t.png logo2t.png -background none -geometry +10+10 -tile 2x2 tmp.png

But then if you put a checkerboard under the whole montage, it will show between the images.

So you may have to put the checkerboard under each image first.
Last edited by fmw42 on 2010-05-17T20:03:45-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

this ought to give you a start

Image

convert \( -size 320x240 pattern:checkerboard -auto-level \) logo2t.png -composite logo2t_check.jpg
montage logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg -background none -geometry +10+10 -tile 2x2 logo2t_montage.png
convert \( -size 680x480 xc:red \) logo2t_montage.png -composite \( -size 680x40 -background red -fill black -gravity center label:"THIS IS A TEST" \) +swap -append logo2t_montage_label.jpg

Image
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Re: Help needed creating layered contact sheet w/ alpha tran

Post by ohai »

fmw42 wrote:To shift things down, you have to create a label image as I said above and then append it to your image. Or use -gravity to composite your montaged result onto a larger background.
So the header section I have at the top of my sample would need to be saved as a separate external image and then inserted during the processing..?
fmw42 wrote:Not sure if you want the result to be 512x512 including the label or if you want the montage to be 512x512 and then add extra space for the label at the top or bottom, so that the final image is larger than 512x512. Please clarify.
Yes, I need the resulting image to be entirely contained inside the 512x512 space, including the header label at the top.
fmw42 wrote:Also it does not look like montage supports transparent images.
tried this
montage logo2t.png logo2t.png logo2t.png logo2t.png -channel rgba -alpha on -geometry +10+10 -tile 2x2 tmp.png
but alpha channel was removed. This may or may not be a bug.
The code I had worked up when I was tearing my hair out before posting (the code I pasted in my original post) does support alpha in the images using montage. I don't know if it makes a difference but I'm using ImageMagick-6.5.6-10 and using the code I pasted in my original post this is what I get:

Image

It has 2 faults however... It doesn't do the checkerboard, and the overall size of the final output is cropped to the grid plus padding, not the full 512x512 but 512x384, even when it includes "e:\Contact_Sheet_Backdrop.tga" which is a 512x512 image itself. (the script I pasted uses 4x3 as the grid, so it creates a 3rd row even though there's nothing to fill it with)

EDIT: Actually it has 3 faults.. it doesn't push the overall grid down to reveal the header space at the top but as you're saying the header needs to be appended to the image...

-ohai
Last edited by ohai on 2010-05-17T20:07:50-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

see my edited note above about montage and transparency. You can have it, but then the area between images will be transparent. So if you composite this with a checkerboard under it, the checkerboard will show between the images.

With regard to 512x512 total, you need to resize your images saving some room at the top, such as 480x512 and then append your label of 32 pixels at the top (similar to what I did above).
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Re: Help needed creating layered contact sheet w/ alpha tran

Post by ohai »

I'm gonna test out your example (thank you for that) and see if I can make it work.. One question re the code you posted.. where you have

label:"THIS IS A TEST"

Can the label be an appended image, or does it have to be a text label? I'll read up on the 'label' function but just thought I'd ask.

-ohai
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help needed creating layered contact sheet w/ alpha tran

Post by snibgo »

Putting the checkerboard under each image first seems the obvious plan, perhaps with the following command so we don't need to know the size:

composite -compose Dst_over -tile pattern:checkerboard logo2t.png logo2t_check.png

Then montage, specifying 4 columns but number of rows will be calculated:

montage logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg logo2t_check.jpg -background none -geometry +10+10 -tile 4x logo2t_montage.png

EDIT: montage can take a "-title", which might help.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help needed creating layered contact sheet w/ alpha tran

Post by fmw42 »

EDIT: montage can take a "-title", which might help.
But the title is on each image as I understand it. Unless you do a second montage on the whole montaged image to add the overall title. But then it will make the image larger. So it adds nothing much except perhaps a bit simpler than using append with label:
ohai
Posts: 21
Joined: 2010-05-17T12:33:12-07:00
Authentication code: 8675308

Re: Help needed creating layered contact sheet w/ alpha tran

Post by ohai »

Right.. ideally I would like to just reuse the same backdrop image under every contact sheet for consistency, and that backdrop has the logo/header/title/whatever already included in it at the top. I may want to add, using regular text, a specific series title, possibly right-aligned inside that header space, but the main logo/header would ideally be contained as part of that backdrop image over which the tiles are all sitting.

Is it possible to wildcard the list of input images to just *.tga? I'm looking at about 16000 images across several hundred folders and subfolders which need to be compiled so writing out the filenames in the command line isn't feasible.

-ohai
Post Reply