PNG sequence to SWF
I needed to stitch a stack of PNG images into a SWF using a server process. There are quite a few tools and methods for doing this interactively, but it gets painful if you want an unattended process.
I found SWFTools (includes PNG2SWF.EXE), which handles the awful, complex bit of … building a SWF from a bunch of PNGs, but then I needed to figure out how to get it to auto-magically use all the PNGs in a specific folder. Essentially, I found a tool that does the hard part, but I needed to cobble together the actual command it should use. Wince if you want to, but I’m a masochist and I hacked together this batch file (like it’s 1988, baby):
@echo OFF
SET LIST=
REM Build a list of PNGs
for /f "delims=" %%a in ('dir /b /a-d %1*.png 2^>NUL') do call :process %%a %1
@echo ON
REM now make a SWF!
CALL png2swf -r 20 -o %2 %LIST%
SET LIST=
goto :eof
:process
REM append the next file to the LIST variable
if not "%LIST%"=="" set LIST=%LIST%
set LIST=%LIST%%~2%~1
example usage — test.bat c:\path\pngFolder c:\path\resulting.swf
I’m sure this is dead easy in linux (you can get swftools in linux flavors too, including source), and I’ll send cookies to whoever posts the first working script in the comments.
Note: I’m not sure why this is, but the resulting SWF can’t be imported into Flash CS3 as one would expect. If you were going to do that, you could’ve imported the initial sequence in the first place.
How would you use the .bat file? Give me a tutorial on that
@Ish: Are you really so lazy you can’t read the whole article?
hi..
first, the LIST was generated without separator. like: c:\asd01.pngc:\asd02.pngc:\asd03.png
when i call as manualy separated, the error is:
Interlace mode 1 not supported!
how now?
Juse use another programming language to generate the query
for instance of PHP I did this:
<?
for($i=0;$i<=1000;$i++){
$str.=”Files/$i.jpg “;
}
echo system(“jpeg2swf.exe -o movie.swf -q 100 -r 15 -z -M -X -Y -f -e $str”);
?>