Using ImageMagick CLI To Watermark Image Via Macro Scheduler

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
NickD
Pro Scripter
Posts: 58
Joined: Fri Sep 23, 2016 2:17 pm

Using ImageMagick CLI To Watermark Image Via Macro Scheduler

Post by NickD » Tue Feb 13, 2018 5:55 pm

Hi, I am trying to create a script that can watermark images in different places based on my dialog input
I have installed Image Magick, and watermarking works fine if I open command prompt from the folder containing the images and use the command:

Code: Select all

magick composite -geometry +50+50 watermark.png originalimage.png compositeimage.png
I can also open cmd at the image folder using something like:

Code: Select all

Run>cmd /k "cd /d C:\Users\Shaolin Nick\Desktop\"
But then I can't send text to the CMD because it does not accept input from send> or even VK keys via user32.dll
Is there is a way to pass the command string along with the cd path so that prompt opens on the correct folder and runs the string?

Also I have seen other examples on the forum of people using Image Magick via RunProgram>, the logical permutation of suggested code for my task would seem to be:

Code: Select all

RunProgram>C:\Program Files\ImageMagick-7.0.7-Q16/composite.exe composite atop -geometry +50+50  c:/path/watermark.png c:/path/originalimage.png c:/path/compositeimage.png
But that is not working for me either, I have also tried double quotes around the parms to no effect..
Anyone got any suggestions?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Using ImageMagick CLI To Watermark Image Via Macro Sched

Post by Marcus Tettmar » Tue Feb 13, 2018 6:41 pm

You have a space in the path so you'd probably need:

RunProgram>"C:\Program Files\ImageMagick-7.0.7-Q16/composite.exe" composite atop -geometry +50+50 "c:/path/watermark.png" "c:/path/originalimage.png" "c:/path/compositeimage.png"

Could also try:

RunProgram>cmd /c "C:\Program Files\ImageMagick-7.0.7-Q16/composite.exe" composite atop -geometry +50+50 "c:/path/watermark.png" "c:/path/originalimage.png" "c:/path/compositeimage.png"

Test it. Copy the command string above to a command window. If it works it should work from RunProgram.

You shouldn't need to send keystrokes into the dos window. I've never done that. You could always make a .bat file if you want to issue multiple commands at once, e.g. CD folder first, and then RunProgram your .bat file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

NickD
Pro Scripter
Posts: 58
Joined: Fri Sep 23, 2016 2:17 pm

Re: Using ImageMagick CLI To Watermark Image Via Macro Sched

Post by NickD » Tue Feb 13, 2018 7:03 pm

First one worked, thanks Marcus you are a star, that has made my evening.
I spent about eight hours trying to get that working, never even occurred to me that a space could be the problem...

User avatar
Grovkillen
Automation Wizard
Posts: 1021
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Using ImageMagick CLI To Watermark Image Via Macro Sched

Post by Grovkillen » Tue Feb 13, 2018 7:31 pm

NickD wrote:First one worked, thanks Marcus you are a star, that has made my evening.
I spent about eight hours trying to get that working, never even occurred to me that a space could be the problem...
A space is always the problem :P
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts