magick chunk.tif -density %%[fx:w/8.26] chunk.pdf works fine but I want to make a loop for a series of images with this batch:
for /l %%a in (1,1,%1) do (
call magick p%%a.tif -density %%[fx:w/8.26] q%%a.pdf
)
and when I type mybatch 5 I obtain magick: invalid argument for option 'density' 'w/8.26]' ar CLI arg 2 @error/operation.c/CLISettingOptionInfo/726 at every image.
It seems the argument of -density is cropped in this context. Why? If there is no loop magick works fine in a batch.
Using -density in a loop in a batch in Windows 10
-
- Posts: 41
- Joined: 2016-10-04T02:08:22-07:00
- Authentication code: 1151
- Location: Nice, France
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Using -density in a loop in a batch in Windows 10
"call" is used to call a batch (BAT) script. magick.exe is a binary program, not a BAT script.
snibgo's IM pages: im.snibgo.com
-
- Posts: 41
- Joined: 2016-10-04T02:08:22-07:00
- Authentication code: 1151
- Location: Nice, France
Re: Using -density in a loop in a batch in Windows 10
Thanks. But in a more complicated case I have to use call for the parameter substitution to work well, e.g.
for /l %%a in (1,1,%1) do (
set /a mypage = "2*%%a +1"
call magick p%%mypage%.tif q%%mypage%%.pdf
)
This fails if you remove "call".
for /l %%a in (1,1,%1) do (
set /a mypage = "2*%%a +1"
call magick p%%mypage%.tif q%%mypage%%.pdf
)
This fails if you remove "call".
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Using -density in a loop in a batch in Windows 10
I've never used Windows 10. (I use 8.1) In all previous versions, "call" is wrong for running an exe program.
For your magick line, you should use delayed expansion of the variable "mypage" (because it has to be expanded in each loop repetition, not just once at the start). So the script looks like this:
For your magick line, you should use delayed expansion of the variable "mypage" (because it has to be expanded in each loop repetition, not just once at the start). So the script looks like this:
Code: Select all
setlocal enabledelayedexpansion
for /l %%a in (1,1,%1) do (
set /a mypage = "2*%%a +1"
magick p!mypage!.tif -density %%[fx:w/8.26] q!mypage!.pdf
)
snibgo's IM pages: im.snibgo.com
-
- Posts: 41
- Joined: 2016-10-04T02:08:22-07:00
- Authentication code: 1151
- Location: Nice, France