Adjust dimensions of montage with G'Mic

(E N) #1

Is it possible to control the dimensions of G’Mic montages from the command line? I’d like to make montages that are the dimensions of my laptop (1600x900) but haven’t seen documentation that describes this.

I tried the following command with the gimp-canvas filter:

gmic *jpg -gimp_canvas 1600x900 -gimp_montage 4,\""V(H(0,1),H(2,V(3,4)))"\",1,1.0,0,5,0,0,0,255,0,0,0,0,0 -o output."$(date)".jpg

But it returned the error:

[gmic]-42./ *** Error *** Command '-gimp_canvas': Undefined argument '$4', in expression '$4' (for 1 argument specified). [gmic] Command '-gimp_canvas' has the following description: [gmic] Command 'gimp_canvas' has no description (did you mean '-gimp_lava' ?). Try 'gmic -h' for global help.

(Pat David) #2

Could you create the montage and then resize to your desired dimensions?
I’m not savvy enough with my G’MIC scripting to know where best to include
this in the pipeline…

(David Tschumperlé) #3

I’m not sure I’ve understood precisely what you want to achieve.
If you have images with general sizes as input, what you can do is :

  1. Do the montage with the scaling parameter set to 1 (max value, and it seems that is what you are doing).
  2. Downscale the result to a width of 1600 or a height of 1900. But this means one of the dimension (width or height) won’t fit exactly the value you are looking for. But at the same time, this is not possible to get exactly this value if you have input images with arbitrary size, without losing the aspect ratio of some images in the process.

Anyway, command gimp_canvas is not invoked correctly in your command. Not sure what you are trying to do here.
I would propose more something like:

$ gmic *.jpg -montage "X",3,0 -resize2dx 1600 -o output.jpg

(E N) #4

Thanks for the replies!

I want a way to control the general dimensions of the output montage. It doesn’t need to be exact.

So instead of the following montage (at the top), which is what I get if I use the command I posted above, I’d like to have a command which would make it possible to make the montage wider (like the one at the bottom):

BTW, I didn’t create the bottom montage using G’Mic, but just copied and pasted the duplicate montage next to the original.

(David Tschumperlé) #5

Have you read the Pat David’s tutorial about Montage?

You can specify your own arrangement for the images, which is probably a part of the solution.

(PJ) #6

I rarely post anything anywhere bc I hate creating accounts, but I feel so passionately about this that I had to respond.

First, This is a TOTALLY AWESOME tool. Thanks so much for writing it!!!

That said, E11 is totally right. We really badly need the ability to give it the approximate dimensions of the output. I’m sure 90+% of users are trying to fill a very specific space, just like E11 and I. (I’m writing to fill the space for a 16x9 video.) I’m sure there are a few uses for web sites and the like where people can scroll to wherever they need to scroll based on your returns, but for everyone who is trying to use this to fill a specific space, it becomes really difficult.

The problem is exacerbated by the fact the GMIC doesn’t produce accurate previews. Otherwise, it would be fine if I kept “cycling” till I got the rough dimensions I want. But instead, I basically have to keep saving at random, regardless of previews, and hoping for the right dimensions. For higher numbers of photos, this becomes time consuming. (BTW, I recently tried on around 50 photos, and the app crashed… The best I’ve done successfully so far is about 36. I know there must be limitations but I was hoping to get to 100 or so…)

Last but not least, yes I did read Pat’s post before I read this one, indeed before I ran into this difficulty much. The problem with custom, of course, is that the whole reason we are using this app is so we don’t have to layout every single photo. We are trying to find an automatic way of building these montages with minimal effort. Trying to create a custom layout for 50 photographs in a “random way” is exactly what we hope to avoid.

Just to give you a usage case, here’s a little more detail on mine: I’m trying to combine almost 600 photos into as few “slides” as possible. The intent is not to show fine details for most of them, but rather the variety amongst them. I was zooming from 1 to 4 to 9 to 16 and so on, to show how the complexity multiplied. By the time I got to 36 and 49, my intent was not to show things very clearly, as long as people could see that, look, there are 50ish different photos here that you can just kind of see. I was hoping a nice recursive algorithm could handle that for me, but I guess the memory usage is just too high at the numbers I want to get to. I’m, going to start having to divide and conquer manually, doing 24+25 and then putting them side by side to get my 49, etc. Still, it would be nice to be able to control the dimensions of the outputs. If I could just specify 2 8x9’s, I could more easily put them together for my 16x9.

Anyway, still great software, but I just feel like you’ve done 99% of the work to making this thing perfect and usable for all use cases, so I wish you could just give us the last piece of the pie.



@dreamdreamfruit Welcome to the forum! Hope you enjoy your stay :slight_smile: and feel that your account creation was worth it.

I recommend using ImageMagick. It has advanced montage and tiling features, so much so that you can do what you want in 5 different ways. To get started, check out @patdavid’s post: Imagemagick Montage Contact Sheets. Also refer to their documentation and forum: