I have a script that converts a PDF to JPG in the correct aspect ratio.
magick.exe c:\test\2.pdf -page A4 -set option:wd "%[fx:(4/3)>(w/h)?(4/3*h):w]" -set option:ht "%[fx:(4/3)>(w/h)?h:(w/(4/3))]" -gravity center -background white -extent "%[wd]x%[ht]" c:\test\2.jpg
I have 2 questions:
Is it possible to create a batch file that will perform conversions for the input file PDF downloaded from the Internet. Something like open in 'convert.bat' where the result will be JPG in the specified location.
Is it possible to set a variable name of the output file
I was able to create a batch file. I adds below. Maybe it will be useful to someone.
@echo off
setlocal
set INIMAGE="%~1"
magick ^
%INIMAGE% ^
-set filename:f "%%[t]" ^
-page A4^
-set option:wd "%%[fx:(4/3)>(w/h)?(4/3*h):w]" ^
-set option:ht "%%[fx:(4/3)>(w/h)?h:(w/(4/3))]" ^
-gravity center ^
-background white ^
-extent "%%[wd]x%%[ht]" ^
"c:\test\%%[filename:f].jpg"