Windows batch files?

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
PA_Kid

Windows batch files?

Post by PA_Kid »

Hello all,

Fmw42 was kind enough to provide some commands that I was looking for, however I'm trying to get these to work on a Windows machine using batch files. As of right now, the Unix style formatting of the commands isn't working fully, and I have a feeling it's a single quote ( ' ) vs double quote ( " ) issue.

Here's the original link: viewtopic.php?f=1&t=13180&start=0

Here's what I'm working with so far:

Code: Select all

set color="convert test.jpg -format '%%[pixel:s.p{0,0}]' info:"
convert test.jpg -background "%color%" -gravity center -splice 0x60 -gravity south -chop 0x60 test2.jpg
I changed Fmw42's Unix style variable to a DOS style variable in the first line, and then I'm attempting to call that variable in the second line with the "%color%". However, the double quotes in the second line ends up spewing out two copies of the test.jpg file - both with black space where the splice happened.

Any help would be greatly appreciated!
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Windows batch files?

Post by el_supremo »

You didn't completely translate Fred's original command. Unfortunately, the effect of a backtick ` in UNIX can't be directly translated to DOS but Anthony has a neat workaround using the FOR command - described here

This should do what you want:

Code: Select all

FOR /F "tokens=*" %i IN ('convert test.jpg -format "%[pixel:s.p{0,0}]" info:') DO convert test.jpg -background %i -gravity center -splice 0x60 -gravity south -chop 0x60 test2.jpg
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Windows batch files?

Post by anthony »

The credit for that neat trick is to Thorsten Röllich (address withheld)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply