Overlaying image with text and aut. adj. text size

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
spilker

Overlaying image with text and aut. adj. text size

Post by spilker »

Hello,

i want to overlay images of any size with an overlay text like "Restricted". The width of the overlay text should match the width of the original image (and the height choosen automatically). I need to this with one call to convert. I was now experimenting some hours with this problem with no results. The problem is the "one call to convert". This is mandatory as conversion takes part of the EMC Documentum Media transformation server (which includes ImageMagick as plugin). Only the commandline to the convert call is configurable. I can´t do any piping or similar.

Greetings, Joerg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Overlaying image with text and aut. adj. text size

Post by fmw42 »

try either

Image

ww=`convert zelda3.jpg -format "%w" info:`
convert zelda3.png \( -background none -size ${ww}x -fill black \
-font Helvetica label:"restricted" \) \
-gravity north -compose over -composite zelda3_tmp.jpg

or

convert zelda3.png \( -background none -size $(convert zelda3.png -format "%w" info:)x -fill black \
-font Helvetica label:"restricted" \) \
-gravity north -compose over -composite zelda3_tmp2.jpg

Image

This is unix. for windows see http://www.imagemagick.org/Usage/windows/
spilker

Re: Overlaying image with text and aut. adj. text size

Post by spilker »

This is the problem. I can´t break it into two commands or get the size of the original image by an inline convert call. On the MTS host you will not find any convert.exe or composite.exe. There´s only an IMW_ComServer.exe which is running always as a task. The concrete call to transform an image is done by some java server which generates a commandline and passes this commandline to the ComServer. I have to achieve the transformation with a plain call to convert.

I´v thought about drawing two lines (from NW to SE and SW TO NE) on the image (instead of the Restricted text). But from all the line drawing examples, it seems that the -draw command only nows about absolute coordinates.

Anyway what i need is some code to make the image unusuable for publication but people should still be able to recognize what´s represented on the picture.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Overlaying image with text and aut. adj. text size

Post by Bonzo »

Here is an example you could possibly use based on a previous post in this forum:

Code: Select all

<?php 
exec("convert -size 140x80 xc:none -fill grey -gravity NorthWest \
-draw \"text 10,10 'Copyright'\" -gravity SouthEast \
-draw \"text 5,15 'Copyright'\" miff:- | composite \
-tile - ../original_images/House.jpg tiled_text.jpg");
?> 
You could have the copyright image on your server anyway and just use the composite part ?
Image
spilker

Re: Overlaying image with text and aut. adj. text size

Post by spilker »

It´s still using a pipe so i can´t use it. Everything must be done within a single convert call.
spilker

Re: Overlaying image with text and aut. adj. text size

Post by spilker »

I think this would also fit my needs:

convert original_pic.tif -size 10000x10000 tile:rings.jpg -compose blend -set option:compose:args 20 -composite target_picture.tif
Post Reply