Hello,
I trying to get checkerboard pattern instead of transparency when converting PNG to JPG. I need to convert and resize a lot of PNG files (900 directories with 1,000 files in each directory).
I am using Windows 7 with IM version 7
I have solution for single file:
Code: Select all
magick ^
example.png -set option:wxh "%wx%h" ^
( -size "%[wxh]" tile:pattern:checkerboard -brightness-contrast 40,10 ) ^
+swap -compose over -composite ^
-thumbnail 340x -quality 80 -filter Lanczos example_tn.jpg
it works perfect, but for single file.
When I trying to create a Batch file:
Code: Select all
@Echo Off
Setlocal
color 0a
set "Source=%~dp0"
cd /d "%~dp0"
if not exist ".\*.png" (
echo.
echo ======================== FAILED! Files *.png not found. ========================
echo.
pause
endlocal & exit
) else (
echo.
echo: Lossy compress all PNG in a Directory:
echo: %Source%
if not exist Compressed mkdir Compressed
for %%i in (*.png) do (
magick ^
"%%i" -set option:wxh "%wx%h" ^
( -size "%[wxh]" tile:pattern:checkerboard -brightness-contrast 40,10 ) ^
+swap -compose over -composite ^
-thumbnail 340x -quality 80 -filter Lanczos ^
".\Compressed\%%~ni_Compressed.jpg"
)
)&& cls
echo.
echo -----------------------------------------------------
echo Process done!
echo -----------------------------------------------------
echo.
pause
endlocal & exit
and run it, this gives an error:
Code: Select all
magick: MissingArgument `-size`at CLI arg 6 @ fatal/magick-cli.c/ProcessCommandOptions/447.
"+swap" is not recognized as an internal or external command...
Thanks in advance for any help.