Page 1 of 1
trying to make a simple bulk image program having issues
Posted: 2011-10-21T07:23:27-07:00
by guitarist24000
The idea of my program is to take all the pictures in one folder and apply the following
First expand the image canvas vertically with a white background
From there it should then put the specified text in every corner
however my code isn't working and probably has errors all over it, Im using windows command prompt to run it with a batch file
here is my code:
Code: Select all
cd "C:\Users\Gregg\Desktop\imagemagick portable\ImageMagick-6.7.3-1"
mogrify.exe -background white -extent 110% -gravity center C:\Users\Gregg\Desktop\testimages\* \
mogrify.exe -gravity SouthWest -draw "text 10,10 'Sales@alltest.net'" \
mogrify.exe -gravity NorthWest-draw "text 10,10 'Alltest Instruments'" \
mogrify.exe -gravity SouthEast -draw "text 10,10 '(123) 456-7890'" \
mogrify.exe -gravity NorthEast -draw "text 10,10 'Express Test'"
pause
this is my fist time using imagemagick, I'm very used to ifranview but unfortunately ifranview cant accomplish what I want. Can anyone help me make my code properly work?
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-21T09:49:50-07:00
by fmw42
you have to cd to the directory you want to process the images or put the full path to that directory in each of your mogrify commands. However, doing so will write over each of your original images. You may be safer using a different output directory using the -path option.
see
http://www.imagemagick.org/Usage/basics/#mogrify
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-21T10:25:10-07:00
by Bonzo
I would probably use convert and do the file selecting in the batch script. I am not a batch script expert and have a couple of scripts on my site I have written and one from someone else that will probably help you out.
Batch script example page
I think you can do eveything you want done with Imagemagick in one convert line; something like:
Code: Select all
::Turn of displaying the code on the screen
@echo off
:: Read all the jpg images from the directory, vertical extent, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do ( convert "%%f" -background white -gravity center -extent x110% ^
-fill black ^
-gravity SouthWest -annotate +10+10 "Sales@alltest.net" ^
-gravity NorthWest -annotate +10+10 "Alltest Instruments" ^
-gravity SouthEast -annotate +10+10 "(123) 456-7890" ^
-gravity NorthEast -annotate +10+10 "Express Test" ^
"%2\%%~nf.png" )
Thinking about it there may be a problem with the -gravity in the extent messing up the gravity for the text - hopefuly this problem will be sorted in version 7. You may have to save an intermediatry image.
Run method in command line:
Code: Select all
name_of_script "path to read images from" "path to save images to"
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-21T10:56:54-07:00
by fmw42
as long as the gravity is reset after the -extent, it should be fine, as far as I know.
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-21T12:31:32-07:00
by Bonzo
Just had a play with this and could not get it to work. I formated my PC last week and the only photos I had were the Windows sample ones and after about an hour of failing I uploaded a photo of my own to try and it worked! For some reason I could not modify the Windows sample photos.
Anyway seems to work just need to escape the % in 110% so it becomes 110%%
The font size could be a problem if you are working in percentages for the image size.
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-27T07:35:21-07:00
by guitarist24000
Bonzo wrote:I would probably use convert and do the file selecting in the batch script. I am not a batch script expert and have a couple of scripts on my site I have written and one from someone else that will probably help you out.
Batch script example page
I think you can do eveything you want done with Imagemagick in one convert line; something like:
Code: Select all
::Turn of displaying the code on the screen
@echo off
:: Read all the jpg images from the directory, vertical extent, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do ( convert "%%f" -background white -gravity center -extent x110% ^
-fill black ^
-gravity SouthWest -annotate +10+10 "Sales@alltest.net" ^
-gravity NorthWest -annotate +10+10 "Alltest Instruments" ^
-gravity SouthEast -annotate +10+10 "(123) 456-7890" ^
-gravity NorthEast -annotate +10+10 "Express Test" ^
"%2\%%~nf.png" )
Thinking about it there may be a problem with the -gravity in the extent messing up the gravity for the text - hopefuly this problem will be sorted in version 7. You may have to save an intermediatry image.
Run method in command line:
Code: Select all
name_of_script "path to read images from" "path to save images to"
Im sorry one last question, what do I use to run this properly
I created the file and named it "watermark" with no extension, put it on the desktop, and to tried calling it in cmd I said
Code: Select all
watermark "C:\Users\Gregg\Desktop\testpics" "C:\Users\Gregg\Desktop\testpics\watermarked"
should my command be something like
Code: Select all
mogrify.exe -"C:\Users\Gregg\Desktop\watermark" "C:\Users\Gregg\Desktop\testpics" "C:\Users\Gregg\Desktop\testpics\watermarked"
?
Thank you for any help your able to give
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-27T08:40:09-07:00
by Bonzo
I wonder if I had another problem as I found the batch file in the c folder.
I gave the file a .bat extension and ran it using:
Code: Select all
test.bat "C:\Users\Anthony\Pictures\TEST" "C:\Users\Anthony\Pictures\TEST"
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-28T10:02:29-07:00
by guitarist24000
Okay problem... nothing happens, I tried running it in windows 7 and windows xp
my exact file is:
watermark.bat
Code: Select all
::Turn of displaying the code on the screen
@echo off
:: Read all the jpg images from the directory, vertical extent, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do ( convert "%%f" -background white -gravity center -extent x110%% ^
-fill black ^
-gravity SouthWest -annotate +10+10 "Sales@alltest.net" ^
-gravity NorthWest -annotate +10+10 "Alltest Instruments" ^
-gravity SouthEast -annotate +10+10 "(732) 123-1234" ^
-gravity NorthEast -annotate +10+10 "Express Test" ^
"%2\%%~nf.png" )
pause
and the exact command I'm running is:
Code: Select all
watermark.bat "C:\Documents and Settings\XPMUser\Desktop\testimages" "C:\Documents and Settings\XPMUser\Desktop\testimages\watermarked"
I put a pause at the end of the batch file to try to troubleshoot, but it doesn't even pause. Any ideas as to what the problem is? I know for a fact Imagemagick is installed properly and works from command line.
edit:: nvm I fixed it by putting everything on one line in the batch file, now its running properly
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-28T10:43:29-07:00
by fmw42
doesn't mogrify require an * as the filename
see
http://www.imagemagick.org/Usage/basics/#mogrify
Re: trying to make a simple bulk image program having issues
Posted: 2011-10-28T11:06:06-07:00
by Bonzo
The new lines after the ^ need to start with a space and for some reason the code when posted above automaticaly stripped it out!