Monatage Labeling

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
akovia
Posts: 3
Joined: 2012-08-22T05:11:15-07:00
Authentication code: 67789

Monatage Labeling

Post by akovia »

Hi,
Been fiddling for a couple days now trying to get this just right but feel like I'm starting to spin my wheels. In short I'm trying to label my storyboard thumbs.

xubuntu 12.04 Precise
Version: ImageMagick 6.6.9-7 2012-04-30 Q16

In detail:
I would like to have a defined image size when I'm done (600x800) with the title of the video placed at the bottom in the padded space. (possibly adding a semi-transparent frame around the image or border the sides with film sprockets)

The script I'm using will always create an image width of 600x, but the height can change depending on the aspect of the video. This should afford me the space for labeling on my 16:9 videos which are the bulk of my collection. The 4:3 videos however result in an image over x900. For these I just want to distort/squish the height enough to add the label and keep the result at x800.

I'm not even sure how to start in handling the padding/squish, but the script as it is now will produce the basic result I'm seeking minus the frame. If I could get some ideas of how to pad/squish properly and any advice on where I should add the frame commands in the sequence it would be a big help.

Thanks,
Ako

Code: Select all

#!/bin/bash
# Script to create a storyboard montage from any video file that 
# ffmpegthumbnailer supports.
 echo "–> Generating thumbnails with ffmpegthumbnailer"
 montagefiles=""
# Next command determines how many & at what % the thumbs are created
# Also used to create outputfilename.
 for i in {5..90..5}
 do
    fileProper=$(readlink -f "$1") # full path of file
    pathNoExt=${fileProper%.*} # full path minus extension
    fname=`echo "$fileProper"`
    echo "$fname"
    outputfilename="seek-${i}.png"
    # Set ffmpegthumbnailer options here.
    ffmpegthumbnailer -i "${1}" -t "${i}%" -o "${outputfilename}" -s 200 
    montagefiles="${montagefiles} ${outputfilename}"
    echo -n ".${i}%"
 done
 echo
 echo "–> Creating montage with ImageMagick"
# Set montage options here. 
 montage -geometry +0+0 -tile 3x6 -background none -fill white \
 ${montagefiles} "${pathNoExt}"_temp.png
 echo "–> Adding Border & Label"
 piclabel=`echo "${fileProper}" | sed 's/^\/.*\/\(.*\)\ \[.*\....$/\1/'`
 convert "${pathNoExt}"_temp.png -background black -fill white -font Verdana\
 -size 550x -gravity center\
 label:"${piclabel}"   -gravity South -append \
 "${pathNoExt}".png
 echo "–> Cleanup:Removing individual temporary thumbnails"
 for i in {5..90..5}
 do
     rm -f "seek-${i}.png"
 done
 echo "Done."
akovia
Posts: 3
Joined: 2012-08-22T05:11:15-07:00
Authentication code: 67789

Re: Monatage Labeling

Post by akovia »

Well after considerable fiddling I came up with an acceptable result. I really wanted to limit the text area so if I run into a very long filename it wouldn't stretch the canvas, which would make the thumbs smaller. All attempts to use the -size option affected the entire image instead of just the text as I wanted. Somehow I'm not using my parenthesis correctly as I always got an error.

For anyone interested, here's the script and a screenshot.

[img]http://eidolen.sent.com/photos/Katanaga ... BCEA8].png[/img]

Code: Select all

#!/bin/bash
# Create a storyboard montage from any video file that ffmpegthumbnailer supports
# 
# ffmpegthumbnailer version: 2.0.7
# ImageMagick 6.6.9-7 2012-08-17 Q16
#
#################################################################

if test -t 1; then
   # Stdout is a terminal.
   exec >ffthumb.log 2>&1
else
   # Stdout is not a terminal, no logging.
   false
fi
  montagefiles=""
  echo "–> Generating thumbnails with ffmpegthumbnailer" > /dev/tty
# Next command determines how many & at what % the thumbs are created
 for i in {5..90..5}
 do
    fileProper=$(readlink -f "$1") # full path of file
    pathNoExt=${fileProper%.*} # full path minus extension
    fname=`echo "$fileProper"`
    echo "$fname"
    outputfilename="seek-${i}.png"
    # Set ffmpegthumbnailer options here.
    ffmpegthumbnailer -i "${1}" -t "${i}%" -o "${outputfilename}" -s 200
    montagefiles="${montagefiles} ${outputfilename}"
    echo -n ".${i}%"
 done
 echo "–> Creating montage with ImageMagick" > /dev/tty
# Set montage options here. 
 montage -geometry +0+0 -tile 3x6 -background none -fill white \
 ${montagefiles} "${pathNoExt}"_temp.png
 echo "–> Adding Border & Label" > /dev/tty
 # Compositing source file
 filmholes=`echo "/home/akovia/.bin/filmhole-600x800.png"`
 piclabel=`echo "${fileProper}" | sed 's/^\/.*\/\(.*\)\ \[.*\....$/\1/'`
 convert "${pathNoExt}"_temp.png -resize x780 -background black -fill white -font Arial\
 label:"${piclabel}" -gravity center \
 -append -gravity South -extent 600x800\
 "${pathNoExt}"_temp2.png
 composite -gravity center "${filmholes}" "${pathNoExt}"_temp2.png \
 "${pathNoExt}".png
 echo "–> Cleanup:Removing individual temporary thumbnails" > /dev/tty
     rm -f "${pathNoExt}"_temp.png
     rm -f "${pathNoExt}"_temp2.png

 for i in {5..90..5}
 do
     rm -f "seek-${i}.png"
 done
 echo "Done." > /dev/tty
 echo goodbye > /dev/tty
 
Post Reply