I created a script awhile ago and now it seems to no longer work.
I want to take a directory of large images, resize them to a width of 1400 pixels, since height and oreintation will vary. Then add "watermark.png" over the bottom of the image. The PNG "watermark.png" is going to be 1400 pixels wide and will be in the same directory as the images and watermark.
then I had the results go into a "watermarked" folder within the same directory
here is what I used to have working for me. now it no longer works, Please help.
@echo off
IF NOT EXIST watermarked mkdir watermarked
FOR %a in ("*.jpg") DO (convert "%a" -resize 1400x5000 -gravity south -geometry +0+0 null: "watermark.png" -layers composite "watermarked\%~nxa")
PAUSE
batch watermarking entire directory
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: batch watermarking entire directory
If you are using the same wartermark.png on all the images in the directory, why not just use mogrify with alpha composition. See http://www.imagemagick.org/Usage/basics ... fy_compose
Re: batch watermarking entire directory
Ok so I tried the Alpha mask script below, no luck. Nothing happens to the images. I guess im curious what is wrong with the first script. that I used in the past that now doesn't seem to have an affect on the images besides creating a new directory. It took me about a week to create that script and now I am finally reaching out to the community since I have very limited coding/scripting experience
mogrify -alpha Set -draw 'image Dst_In 0,0 0,0 "watermark.png"' mogrify_*.jpg
mogrify -alpha Set -draw 'image Dst_In 0,0 0,0 "watermark.png"' mogrify_*.jpg
Re: batch watermarking entire directory
As you do not say what happens to the first images except " now it no longer works" it is a bit hard to find the problem and you also need to specify your version.
I recommend going back to basics and get the watermark working on one image with direct image name input and then use that code in your batch file.
I recommend going back to basics and get the watermark working on one image with direct image name input and then use that code in your batch file.
Re: batch watermarking entire directory
Thank you both for the speedy responses, This is overwhelming for me and you two have got me going down the right path. I am operating on a windows 7 64 bit machine using the 6.9 version of Imagmagick. And that right there answers the question. The original script had only one "%" in front of my commands instead of "%%" by only typing one i was commenting out the rest of my script. when i went back and doubled all of the "%" it then worked like a charm. The peson who originally helped me was having me use CYgwin terminal and I am more comfortable with CMD line.
Thanks again guys, hope this helps anyone else running into "commenting out" problems
Thanks again guys, hope this helps anyone else running into "commenting out" problems
Re: batch watermarking entire directory
I am glad you are sorted. Anthony has some Windows tips here: http://www.imagemagick.org/Usage/windows/
From memory you need %% in batch scripts but only % in command. Another thing to look out for is you need to use " instead of ' on Windows.
From memory you need %% in batch scripts but only % in command. Another thing to look out for is you need to use " instead of ' on Windows.
Re: batch watermarking entire directory
Sweet thank you Bonzo!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: batch watermarking entire directory
create a new directory for the resultsmogrify -alpha Set -draw 'image Dst_In 0,0 0,0 "watermark.png"' mogrify_*.jpg
cd to the directory you want to process
then try
Code: Select all
mogrify -path path2/newdirectory -format jpg -gravity south -draw "image over 30,30 0,0 'watermark.png'" *.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: batch watermarking entire directory
When a script doesn't work, always remove "@echo off". Then you can see what is happening.
Yes, for Windows BAT scripts, each % in the OP needs doubling. This doesn't of course mean that % should always be doubled. It isn't doubled for environment variables or numbered parameters (eg %WW% and %1). See my pages for many examples of Windows BAT scripts.
Yes, for Windows BAT scripts, each % in the OP needs doubling. This doesn't of course mean that % should always be doubled. It isn't doubled for environment variables or numbered parameters (eg %WW% and %1). See my pages for many examples of Windows BAT scripts.
snibgo's IM pages: im.snibgo.com