How do labelling on 2 lines using %f 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
kalagani
Posts: 3
Joined: 2008-08-03T10:27:27-07:00
Location: France

How do labelling on 2 lines using %f in montage

Post by kalagani »

Bonjour,

I am using below

Code: Select all

montage -background white -label "%f\n%wx%h  %b" -frame 2 -quality 100 \
          -geometry 200x+2 *[0] -title `pwd`  index.jpg
but sometime %f returned is very long, so I want to put it on 2 lines automaticaly or after caracters counting
After search on Internet, reading http://www.imagemagick.org/Usage...
I tried caption, or awk inserted in the code above but without results

I just succeed in doing in a single identify command

Code: Select all

identify -format "%f\n" *[1] |awk '{print substr($0,0,12)"\n"substr($0,13,100)}' 
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How do labelling on 2 lines using %f in montage

Post by anthony »

Label is not a word-wrapped text to image convertor, unfortunatally that is what "montage" uses.

The one which word wraps is 'caption' which is what a '-polarariod' framing operator will use.

see IM Examples, for a montage that uses -polariod..
http://www.imagemagick.org/Usage/montage/#polaroid

The only other thing that can be suggested is to DIY the montage yourself, or pre-process the labeling yourself.

IM Examples "Annotating Images" can help with this.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
kalagani
Posts: 3
Joined: 2008-08-03T10:27:27-07:00
Location: France

Re: How do labelling on 2 lines using %f in montage

Post by kalagani »

Hello Anthony,
I make a workaround to have labelling on 2 lines:
evaluate length of photo, then pre-processing polaroid thumbnails with caption on 1 or 2 lines
so make the index with montage from the thumbnails, end by removing the thumbnails.

Defaults:
Creating intermediate thumbnails, the html is not useful because it is on the thumbnails not on the source!
Lot of blank area between photos in the polaroid index
Each polaroid thumbnail is slightly curved

Do you know solution to solve these defaults?

Thanks

Code: Select all

    for Photos in *
    do 
      if [ -f "$Photos" ]
	  then 
	  datePhoto=`echo "$Photos" | awk '{print substr($0,0,12)}'`
	  nomPhoto=`echo "$Photos" | awk '{print substr($0,14,32)}'`
	  nomPhoto2=`echo "$Photos" | awk '{print substr($0,46,50)}'`
#          Make label with name  on 1 or 2 lines in a polaroid thumbnail
#          *[0] to take only the main picture
	  if [ -z "$nomPhoto2" ]
	      then
	      convert -caption "$datePhoto\n$nomPhoto\n %wx%h  %b" $Photos[0] -thumbnail 240x240 \
	      -polaroid -0 $Photos"_thumb".png
	  else
	      convert -caption "$datePhoto\n$nomPhoto\n$nomPhoto2 %wx%h  %b" $Photos[0] -thumbnail 240x240 \
	      -polaroid -0 $Photos"_thumb".png 2>> "$dateRep"_000_"$themeRep"_convert.error
	  fi
      fi
    done
#    Index from polaroid thumbnails
    echo " index`" type: aaaa-mm-jj-x_theme"
    montage -size 500x500 *_thumb.png -geometry 200x+0+0 -title "$1" -tile 6x \
                     "$dateRep"_000_"$themeRep"_index.jpg
    \rm *_thumb.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How do labelling on 2 lines using %f in montage

Post by anthony »

I am not certain exactly what you are after. It is not very clear.

however if "montage" or a "montage with polaroids" does not do what you want, than your only solution is to try to generate your own version of montage.

That is create thumbnails, pad, annotate, frame, and create an array of images in the way that you require it.

IM can do this...

Sorry that is all I can suggest.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply