how to crop the labels in "montage"?

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?".
Post Reply
jeancallisti
Posts: 1
Joined: 2013-05-30T03:41:32-07:00
Authentication code: 6789

how to crop the labels in "montage"?

Post by jeancallisti »

Hi everybody,

I'm facing the following problem but I don't know how to fix it :

I need to create a montage (using the "montage" tool), and I need to have the file names as label below each image (using -label %f).
However, the file names are quite long, but I can't afford to have a big horizontal gap between each image. So it can't be fixed with -geometry. Vertical gap doesn't matter, though.
Is there a way to cut the label so that it has a fixed width (preferably the width of the image), but it's split on several lines? (regardless of spaces -- i'm not looking for word wrap, just... let's say... characters wrap?)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to crop the labels in "montage"?

Post by fmw42 »

Is there a way to cut the label so that it has a fixed width (preferably the width of the image), but it's split on several lines? (regardless of spaces -- i'm not looking for word wrap, just... let's say... characters wrap?)
No, not that I am aware using montage, since it uses label: and not caption:. You would need to use caption and append the textimage created by caption below each image and then use montage to make your montage.

This could be done in a loop, to create the caption image, append it below the image and save each appended image as a multipage miff file and then pipe that to montage.

Note that to get any wrap of text there must be spaces in the file names. Is that the case with your names?

see
Last edited by fmw42 on 2013-05-30T16:54:11-07:00, edited 2 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to crop the labels in "montage"?

Post by snibgo »

In IM v6.8.5, IM "caption:" will split at words, but if a word is too long it is cropped.

In previous versions (eg v6.8.4), it splits between characters if necessary.
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: how to crop the labels in "montage"?

Post by fmw42 »

snibgo wrote:In IM v6.8.5, IM "caption:" will split at words, but if a word is too long it is cropped.

In previous versions (eg v6.8.4), it splits between characters if necessary.

Can you provide an example. It sounds like a possible bug to crop a word.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to crop the labels in "montage"?

Post by snibgo »

Code: Select all

convert -size 50x200 -box Yellow -pointsize 20 caption:"(abc adadadaddefghijkl)" c.png
In 6.8.4, all the characters are visible. Not so for 6.8.5.

With all the changes around caption etc, I don't know what the "correct" behaviour is supposed to be.
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: how to crop the labels in "montage"?

Post by fmw42 »

I do not think caption is supposed to work if all 3 of width, height and pointsize are specified.

I am not sure but even if you leave off the pointsize it looks wrong to me. The only one that looks reasonable is

convert -size x200 -pointsize 20 caption:"(abc adadadaddefghijkl)" show:

Anthony's current notes at http://www.imagemagick.org/Usage/text/#caption seem to imply that one can use all three, but that seems overdetermined to me. So one must take precedent over the others. He also points out that overflow can happen.

I would post this on the bugs forum and inquire if this is correct behavior, especially if you can show that in IM 6.8.4 it worked better.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to crop the labels in "montage"?

Post by snibgo »

snibgo's IM pages: im.snibgo.com
Post Reply