Page 1 of 1

Creating movieposter, how to optimize/cluster the commands?

Posted: 2014-03-08T19:13:06-07:00
by Lennong
First off I want to thank for a great piece of software, it really gives the creativity some room! :D

I have been fighting for some months with my own metadataposter för my movie collection and finally have a decent result. The imagemagick commands in the shape they are now takes way to long time to parse and I have seen that one can add the commands together. However, after a week I cannot get it to work without having my long liners where I work with the same image over and over. Anyone have any pointer on how I should approach this? Thanks!

Code: Select all

  # Set canvas (720)
echo "Copy canvas.."
  convert "$file" -resize $METASIZE -quality 100 "$WORKDIR/about.png" 
  composite $ART/frame_720.png "$WORKDIR/about.png" -quality 100 "$WORKDIR/about.png"

  # Add Metadata
echo "Adding metadata.."
  convert -background '#0000' -fill white -size 500x162 -pointsize 18 caption:"$PLOT" "$WORKDIR/about.png" +swap -geometry '+300+490' -composite -quality 100 "$WORKDIR/about.png"
  convert -background '#0000' -fill grey -geometry '+0+15' -size 163x30 -pointsize 18 caption:"($RATING/10)" "$WORKDIR/about.png" +swap -gravity northeast -composite -quality 100 "$WORKDIR/about.png"
  convert -font $FONT/b018015l.pfb -background '#0000' -fill orange -size 760x40 -pointsize 32 caption:"$TITLE" "$WORKDIR/about.png" +swap -geometry '+80-2' -composite -quality 100 "$WORKDIR/about.png"
  convert -font $FONT/n019004l.pfb -background '#0000' -fill white -size 85x28 -pointsize 24 caption:"$hour"h" $min"m"" "$WORKDIR/about.png" +swap -geometry '+856+6' -composite -quality 100 "$WORKDIR/about.png"
  convert -background '#0000' -fill white -size 300x20 -pointsize 18 caption:"$DIRECTOR" "$WORKDIR/about.png" +swap -geometry '+987+490' -composite -quality 100 "$WORKDIR/about.png"
  convert -background '#0000' -fill white -size 300x20 -pointsize 18 caption:"$YEAR" "$WORKDIR/about.png" +swap -geometry '+987+526' -composite -quality 100 "$WORKDIR/about.png"
  convert -background '#0000' -fill white -size 300x20 -pointsize 18 caption:"$GENRE" "$WORKDIR/about.png" +swap -geometry '+987+562' -composite -quality 100 "$WORKDIR/about.png"
  convert -background '#0000' -fill white -size 300x108 -pointsize 18 caption:"$ACTORS" "$WORKDIR/about.png" +swap -geometry '+987+598' -composite -quality 100 "$WORKDIR/about.png"
  composite -geometry '+987+07' "$ART/rating/""$STARS"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+296+660' $RESOLUTION "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+356+660' "$ART/video/""$VIDEO_CODEC"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+416+660' "$ART/audio/""$AUDIO_CODEC"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+476+660' "$ART/audio/""$AUDIO_CHANNELS"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+536+660' "$ART/container/""$CONTAINER"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+596+660' "$ART/ratio/""$RATIO"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  composite -geometry '+656+660' "$ART/mpaa/""$AGE"".png" "$WORKDIR/about.png" "$WORKDIR/about.png"
  
  # Create Discbox & Cover
echo "Adding discbox & cover.."
  convert "$WORKDIR/large_box.png" -resize 85% -quality 100 "$WORKDIR/medium_box.png" 
  composite -geometry '+80+398' "$WORKDIR/medium_box.png" "$WORKDIR/about.png" -quality 100 "$WORKDIR/about.png"
The poster:
http://img818.imageshack.us/img818/1088/h69j.jpg

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-08T19:42:57-07:00
by fmw42
It kind of hard to follow all your commands, but keep in mind that you can chain command sets within convert and use convert -composite rather than composite. You can also use parenthesis processing to keep each set of command separate, but that seems optional in this situation.

Code: Select all

convert "$file" -resize $METASIZE -quality 100 "$WORKDIR/about.png" 
  composite $ART/frame_720.png "$WORKDIR/about.png" -quality 100 "$WORKDIR/about.png"

  convert -background '#0000' -fill white -size 500x162 -pointsize 18 caption:"$PLOT" "$WORKDIR/about.png" +swap -geometry '+300+490' -composite -quality 100 "$WORKDIR/about.png"
...

Can be combined as follows in Unix syntax, but note that -quality 100 is probably not correct for PNG files (and should be saved until the end). See http://www.imagemagick.org/script/comma ... hp#quality. Note also that -geometry needs to come before -composite

Code: Select all

convert "$file" -resize $METASIZE $ART/frame_720.png +swap -composite \
-background '#0000' -fill white -size 500x162 -pointsize 18 caption:"$PLOT" -geometry '+300+490' -composite \
... 
etc for each text field you want to add
...
"$WORKDIR/large_box.png" -resize 85% -geometry '+80+398' -composite -quality XX "$WORKDIR/about.png"
The \ at the end of the line mean continue on the next line. Do not put spaces after \. This helps make your command more readable than all on one line.

see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/basics/#parenthesis

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T12:38:37-07:00
by Lennong
Thank you for the reply! I have tried for a few hours and I simply cannot get this right, the method you showed me doesn't work. I'm lost.

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T13:06:51-07:00
by fmw42
What platform and what version of IM?

Can you provide a very simple example with images - perhaps just part of your full result above?

It would make it simpler to explain if I had your images and the exact argument values and a result image.

Or perhaps post the code you are trying according to my notes above.

Another suggestion for debugging is to put a -write tmpX.png right after each -composite, so that you can see what it is doing at each step.

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T13:23:30-07:00
by snibgo
Adding to fmw's advice:

I suggest you change all your "composite" commands into "convert" commands. Then merging them is much easier.

When you have only "convert" commands, start by just merging two commands together. Don't attempt to merge them all together at once.

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T14:52:31-07:00
by Lennong
Thanks for the answer! I did som benchmarking on my process just to see if I could justify not to mess with this more. My poster is generated from variables generated from data pulled from a few xml files with metadata and movieonfo and such. When running the whole shebang with pulling the data and operators on text and so on I generate a poster in 10-12s. If I instead directly put some values in the convert and composite commands it generates in 2s... Maybe my IM commands aint that much a candidate for improving after all.. :? How much can a merging of all the commands give in improved efficiency?

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T14:57:09-07:00
by fmw42
It is hard to say. You save the time reading and writing to the same image over an over.

Re: Creating movieposter, how to optimize/cluster the comman

Posted: 2014-03-09T15:05:08-07:00
by Lennong
Yes, you are right.. Hmm, the purist in me doesn't like that of course. ;)