Lolcats your UCM Conversion Server
By Kyle Hatlestad on Oct 04, 2009
For those using UCM to store images and rendition them using the Digital Asset Management module, it may be useful to add watermarks to those images. Watermarks could be other images such as a corporate logo or text that's applied to the image.
The default 3rd party conversion utility that the DAM Converter is configured for is Image Alchemy from Handmade Software Inc.. While it has a large range of file format support, it does not have the ability to watermark. But DAM Converter can be configured to use ImageMagick instead, which does have watermarking.
To show an example, I thought the Lolcats would be perfect. If you haven't been on the internet for the past two years, you can check out the phenomenon over at I Can Has Cheezburger.
First, go to the Configuration Manager applet and add a new option list entry to the PackagedConversions metadata field called 'LOLCats'. Then go on to the server for Conversion Server and browse to the \custom\DAMConverter\resources\ folder. The Digital Asset Manager Installation and Administration guide walks you through modifying the extraRendition_definitions.hda file in the \data\configuration\dam\ directory, but I've never had much luck with getting that work. Instead, I've defined them directly in the damconverter_basedefinitions.hda file. But I make sure to always make a backup in case I update the DAMConverter component and the changes are overwritten.
So in the .hda file, in the ResultSet ImageManager_TablesLoad section I add my new entries for the new rendition set just above the @end line:
Then in ImageManager_NameValues section, I first add my entries for the ImageMagick executable right under the ones for Image Alchemy:
Then before @end line for that same section, I add the ImageMagick command-line conversion options:
-resize 400x300> -font impact -weight bold -pointsize 32 -draw
So in this example, I'm creating the first 3 standard renditions of Thumbnail, Preview, and Web. Then I have one for logos which will keep the image under 80 pixels wide and 120 pixels high. And the last one is for the text watermark. I define the size of the image to be a max of 400x300 and set the font style, weight, and size. Then I issue the -draw command which will print out the value that is defined next. But i do not define that on the same line. And you'll see why down below. For more details on ImageMagick options, see their website.
Finally, I create the actual rendition set ResultSet for the LOLCats:
<$Imagemagick_Watermark$> "gravity northwest fill white text 10,12 '<$dDocTitle$>'" "<$inFile$>" "<$outFile$>.jpg"
A 72 dpi JPEG no wider than 400 pixels and no higher than 300 pixels
<$Imagemagick_Thumbnail$> "<$inFile$>" "<$outFile$>.jpg"
A 72 dpi JPEG no wider or higher than 80 pixels
<$Imagemagick_Preview$> "<$inFile$>" "<$outFile$>.jpg"
A 72 dpi JPEG no wider or higher than 250 pixels
The key line is where the Imagemagick_Watermark variable is used. This issues the command-line options mentioned above. And then immediately after that I specify the text to draw and its location in the image. In this case, rather then hard-coding the text to display, I pass it the Title that was given to the image when checked in. In order to process the Idoc Script, it needs to be on this line and not the command-line definition above. Unfortunately, not all metadata is passed. But another useful example might be to watermark the Content ID to help tag and identify the image. Now I just save the file and restart the Inbound Refinery.
On the check-in page, I specify my Title and file:
And specify the new Image Rendition Set:
After check-in, I now have this image as my result:
Update 12/29/2009: The command-line entries I had between the command-line definitions and rendition resultsets did match. One had a capital 'M' in the 'ImageMagick_Thumbnail' and the other had 'Imagemagick_Thumbnail'. Both have matching case now. Hat tip to Jason for pointing it out.