Search code examples
imagemagickmontage

How to remove white space between ImageMagick's montage tiles?


I current have code that build a montage using ImageMagick. This is my line of code:

montage -mode Concatenate -tile ${tile} -geometry ${geometry}+0+0 ${input} ${output}

I'm using -label ${label} to name my labels (in my input var).

This gets me a montage with a lot of white space, like that:

enter image description here

I checked on the manual and forums but everyone seem to agree that the way to do this is to use concatenate or geometry +0+0. I am already using those and it does not work. I also read that the font should be automatically chosen to fit the free space. Right now, there is way too much white space.

My goal: To get the white space (between the tiles on the vertical) to fit the current labels height and nothing more.

If you have an idea, I would be really happy.

Thank you anyway guys!

PS: It also doesn't work without labels. I get:

enter image description here

PPS: I'm sorry if my english is not really good, I am french from Montréal, Qc, Canada.


UPDATE: Those are my settings:

tile=4x3
geometry=386x305

Solution

  • The additional white space is coming from your geometry setting. The options -geometry 386x305+0+0 is adding an additional 15px between the image and the label.

    whitespace between image and label

    If you omit the WxH and add a non-zero value to the offset -geometry +0+15, then you'll have additional white space after the label.

    whitepsace after label

    To limit the white space to text height, and nothing more, just keep the option as -geometry +0+0.

    no whitespace

    I also read that the font should be automatically chosen to fit the free space.

    I think that's reversed. The white space is determined by the typeface of the font. I wouldn't say fonts automatically adjust <blank>, but default to <blank>. It's always a good idea to define the font & pointsize.