Reputation: 1856
I'm new to the magick library and also this cmd syntax hurts me so much. I'm trying to achieve the following:
I have 2 folders, each of them contains 100 png files. I want to render a smooth transition between these images like this:
The first image in the first folder should be overlapped with the first image in the second folder with 1% opacity.
The 45th image in the first folder should be overlapped with the 45th image in the second folder with 45% opacity, and so on...
My files are named like frame000.png, frame045.png (padded with zeros), which is further complicates the problem.
I try to achieve this combining a for loop in a batch script and a magick command, but it seems like nothing is happening, when I run it it just prints this text to the cmd window 100 times:
SET NUM=x SET PADDED=00NUM SET PADDED=PADDED:~-3 magick composite -dissolve PADDEDPADDEDPADDEDPADDED.png
I think the problem is in my batch syntax, but I can't figure it out. Heres what I have in render.bat:
FOR /L %%x IN (0,1,99) DO ^
SET NUM=%x ^
SET PADDED=00%NUM% ^
SET PADDED=%PADDED:~-3% ^
magick composite -dissolve %x -gravity Center "frl1/frame%PADDED%.png" "frl2/frame%PADDED%.png" -alpha SET "output/%PADDED%.png"
pause
I tried changing the variable references to %x
, %%x
, %x%
, but none of them gave me the correct results.
Upvotes: 0
Views: 144
Reputation: 56188
your ^
means "Line continuation" - this is not how batchfiles work.
And you need delayed expansion:
Setlocal enabledelayedexpansion
FOR /L %%x IN (0,1,99) DO (
SET PADDED=00%%x
SET PADDED=!PADDED:~-3!
magick composite -dissolve %%x -gravity Center "frl1/frame! PADDED!.png" "frl2/frame!PADDED!.png" -alpha SET "output/!PADDED!.png"
)
pause
(Note: I removed an unnecessary variable)
Upvotes: 1