filename on an image

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
goslings

filename on an image

Post by goslings »

Totally new to this ; want filename on the image as a reference
tried
convert x.png -font Aerial -pointsize 30 -draw "gravity northwest fill black text
0,12 'abcdefg' " xy.png

this writes title "abcdefg" onto file, but is there a way to put the filename title on the image rather than type it and modify the actual file rather than a copy (x.png - xy.png)
lots of files to do in a batch file

tried %f but it does not like it
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: filename on an image

Post by fmw42 »

if you want your image file to be abcdefg.png

str="abcdefg"
convert x.png -font Aerial -pointsize 30 -draw "gravity northwest fill black text
0,12 $str " $str.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: filename on an image

Post by anthony »

Don't use -draw use -annotate and use the string %f

For example

Code: Select all

   convert x.png -font Aerial -pointsize 30 -gravity NorthWest -fill black \
              -annotate 0,12 '%f'  xy.png
If you simply want the filename UNDER the image, you can use montage

Code: Select all

   montage -label '%f' x.png \
          -font Arial -pointsize 30 \
          -geometry +0+0 -background silver xy.png
See IM examples, Montage
http://www.imagemagick.org/Usage/montage/

For many other lableing methods: below, above, or on top of the image; using methods that will work with any image: light, dark, caotic; then look at
IM Examples, Annotating Images
http://www.imagemagick.org/Usage/annotating/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
goslings

Re: filename on an image

Post by goslings »

thanks all
have many files and wanted to write the filename (very long) on each at upper left corner hence the need to use %f
thanks all
Post Reply