G'mic montage+padding

@David_Tschumperle
Salut David,
I’m struggling to find out how to use the montage command and include a margin between the photos (that equals the padding slider in gmic-gimp).

This command
$ gmic [1-4].jpg -montage H,0,0 -o out.jpg
gives four images in a horizontal row, without any space between them.

If I use gmic-gimp and I say Send output to console, I see that the third parameter is the padding number. But when I add that to the command above (so H,0,0,10) I get an error:

[gmic]-4./ Create aligned montage from images [0,1,2,3], with layout code ‘H’ and centering 0.
[gmic] *** Error in ./montage/*if/*repeat/ *** Command ‘input’: File ‘0’, format does not take any input options (options ‘0,0,4000,2250,0,0,0’ specified).

I can use the -polaroid 1,1 option to get the desired result, but I’m quite sure I can do this straight in the montage function.

Any help is appreciated.

Regards, Paul.

Bonjour,

Documentation :
https://gmic.eu/reference/montage.html

frame before montage (frame=frame_xy)

https://gmic.eu/reference/list_of_commands.html#arrays_tiles_and_frames
https://gmic.eu/reference/frame_xy.html

1 Like

To me it seems montage requires lots of fiddling and help. I end up not using montage at all.

Yes frame and montage commands are best friends!

@samj, @afre

Hello samj, thanks for your respons, frame_xy did the job indeed. I studied the documentation about montage already, but couldn’t find the parameter to set the padding (it is available in the gimp-gmic package though).

And afre, I agree that gmic’s montage is a bit difficult to use. I’m working on a project where I need to make a montage of 500 or 1000 small photos, to be printed on a large sheet of paper (say 1 or 2 meter or longer). Therefore I need to control how many photos will be placed in a horizontal row and what the margin is between individual photos in the row and between the rows (vertical).

I found out that I can do this with ImageMagick in the following way:

$ montage *.jpg -auto-orient -rotate 90 -geometry 472x354+5+5 -tile 10 test_500.jpg

(still working on the auto-orient and rotate arguments, sometimes they bite each other).

The +5+5 means: 5px between photos in a row and 5px between rows (that was the argument I was looking for in gmic).
The tile argument says how many photos must be placed in a row.

So problem solved, though not with G’mic. I’ll go on to use them side by side.

1 Like

Bonjour,

Good if you have found a solution to your problem :o)

For fun, here are some examples of command lines for making montages :

gmic fx_image_sample 1,0,0 fx_image_sample 2,0,0 fx_image_sample 3,0,0 fx_image_sample 4,0,0 XY=20 frame_xy $XY,$XY,0 Padding=50 frame $Padding,$Padding,255 montage H

gmic fx_image_sample 1,0,0 fx_image_sample 2,0,0 fx_image_sample 3,0,0 fx_image_sample 4,0,0 XY=20 frame_xy $XY,$XY,0 Padding=50 frame $Padding,$Padding,255 montage V

gmic fx_image_sample 1,0,0 fx_image_sample 2,0,0 fx_image_sample 3,0,0 fx_image_sample 4,0,0 XY=20 frame_xy $XY,$XY,0 Padding=50 frame $Padding,$Padding,255 montage A

gmic fx_image_sample 1,0,0 fx_image_sample 2,0,0 fx_image_sample 3,0,0 fx_image_sample 4,0,0 XY=20 frame_xy $XY,$XY,0 rotate 30 Padding=50 frame $Padding,$Padding,255 montage A

Salut @samj,

Thanks for your examples, appreciated.
The term XY=20 frame_xy $XY,$XY,0 doesn’t work on my system (Xubuntu 18.04), I had to change this to frame_xy 20,20,0, same for the padding term.

Apart from that, do you know by change what I must tell gmic to place 8 photos in a row and repeat those rows until the last photo is placed (think 500 or 1000 photos)?

Appending a list of images in rows with eight: append_tiles 8

Bonjour,

I enclose a small program in the archive ‘paulmatth_montage_raw.zip’
You unzip this archive and place the file ‘paulmatth_montage_raw.gmic’ in the directory of your executable.
You will need to create a batch script to call this little program each time you have the number and names of the images for each row.
Then you can assemble these rows.
Unfortunately you are on Linux and I cannot do this script quickly.

Here are some command lines to use this script and the results :

gmic repeat 10 sample done m paulmatth_montage_raw.gmic paulmatth_montage_raw 10,10,0,20,20,255,1,1800,0 o raw1.jpg

gmic repeat 10 sample done m paulmatth_montage_raw.gmic paulmatth_montage_raw 10,10,0,20,20,255,1,1800,90 o raw2.jpg

gmic repeat 5 sample done m paulmatth_montage_raw.gmic paulmatth_montage_raw 10,10,0,20,20,255,1,600,0 o raw3.jpg

raw3

This little program has 9 parameters :

# $1 = X contour
# $2 = Y contour
# $3 = color contour 0...255

# $4 = X padding
# $5 = Y padding
# $6 = color padding 0...255

# $7 = resize Y (1) or N (0)
# $8 = width pixels

# $9 = orientation

paulmatth_montage_raw.zip (536 Bytes)

Bonjour,

Yesterday I added a command to G’MIC : samj_paulmatth_montage_row
Here is an example to adapt to obtain a montage of 80 photos on a width of 1600 pixels.

The method used:

Update G’MIC to have the commands added recently

gmic update

Creation of 10 files containing 8 images

gmic IndexRow=1000 repeat 10 repeat 8 sample done samj_paulmatth_montage_row 10,10,0,20,20,255,1,1600,0 o $IndexRow.jpg IndexRow={$IndexRow+1} rm done

Assembly of the 10 files to obtain montage.jpg (80 images)

gmic IndexRow=1000 repeat 10 i $IndexRow.jpg IndexRow={$IndexRow+1} done append y o montage.jpg

Salut @samj,

thank you very much for this, very useful. The reason why I need a script like this is that I’m in the process of opening a (fine-art) print shop. I can make prints up to 15m (x60cm max) and I want to offer artists the possibility to print several thousands little photos (5x5, 5x7cm…) on one very large sheet of paper.

One little thing:

paul@graveyron:~$ gmic update
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Update commands from the latest definition file on the G'MIC server.
[gmic] *** Error in ./update/ *** Command 'update' : Unreachable update file.

Same when I try to update gmic in Gimp: network error, content not found. I always have problems updating gmic, so I use the one that is offered by my package manager, currently v2.8.4.

If your binary is still version 2.8.4 you have to upgrade the latter. “update” under gmic tries to read the file update284.gmic from gmic.eu. This file does not exist anymore! You should install the latest binary for your OS, actually 2.9.4.

@samj, @KaRo :
Okay, I cleaned up the Gimp mess on my machine (*), installed the latest gimp-flatpak that came with gmic 2.9.4, did a gmic update in the terminal and now samj’s script works fine, thanks you both!

(*) My regular Gimp was the ppa from Otto Kesselgulash, v2.10.14, but that is no longer maintained. My package manager (Xubuntu 18.04 LTS) only offers v2.8 (!). I had as well a snap version and an flatpak on my machine, to have recent versions (to check my Gimp translations in Dutch, I’m a member of the Gnome translate team). I continued to use Otto’s ppa because that’s the only one where I could access xsane directly from within Gimp. Can’t do that with the flatpak (searching for flatpak xsane gives nothing), but that’s only a minor inconvenience.

1 Like