Page 2 of 2

Re: Using the Filename as Text on the image.

Posted: 2010-05-05T11:55:18-07:00
by Bonzo
There are some batch file examples on my website: http://www.rubblewebs.co.uk/imagemagick/batch.php

You probably want to do something based on this:

Code: Select all

::Turn of displaying the code on the screen
@echo off

:: Read all the jpg images from the directory, resize them, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do ( convert "%%f" -resize 200x200 -pointsize 18 -fill black ^
-gravity northwest -annotate +0+0 "Some text" "%2\%%~nf.png" )

::This batch file was named resize.bat and called using "resize path\to\original\ path\to\save"
I am busy doing PC jobs for the wife at the moment :( and can not spend any time on this until next week.

Re: Using the Filename as Text on the image.

Posted: 2010-05-07T09:42:41-07:00
by Drarakel
If you want to drop a directory (with subdirectories) onto the batch file, try this:

Code: Select all

@ECHO OFF
SET height=60
FOR /R %1 %%i IN (*.*) DO ( 
ECHO Processing "%%i"...
convert "%%i" -background white ( -size 1x%height% xc:white ^) -append ^
  ( -size x%height% -fill black label:"%%~ni" ^) ^
  -gravity southeast -compose over -composite ^
  ( -size x%height% -fill black label:"Protected Document - Attorney Eye's Only" ^) ^
  -gravity southwest -compose over -composite ^
  "%%i"
)
pause
Of course the right height value depends on your set of images. Consider that in the above example, one label will 'erase' the other label if the images are too narrow.
And most important: Be very careful at first, as this will overwrite all of your images! (And if you call the batch without an argument, it will change all the images in the working directory.) So, first test with unimportant copies.