tags:

views:

1045

answers:

3

I'd like to be able to take a 1-frame SWF file and convert it to PNG through PHP. I'm okay with using command-line tools to get this done.

How could I go about doing this? I found an ActiveX library, but that seems like one too many layers. I also see that Gnash seems to have a PNG output class, but I can't figure out how to get to that from the command line without doing some deep coding of my own. Are there any other clever solutions available? Thanks!

EDIT: To clarify, this is not a one-time task I just want to be able to do once. I'd like to be able to have a PHP script perform this task on command. Thanks!

Another EDIT: One more clarification. This is not a situation in which, say, a user makes a drawing in Flash. I am downloading raw 1-frame SWF files, and want to save PNG copies in order to reduce download time. Is such a task possible? Thanks again!

+1  A: 

From Google: Flash screenshot

CookieOfFortune
I'd prefer to start with server-side technologies, then try client-side, since there will always be malicious users out there. But thanks - I'll keep it in mind :)
Matchu
The point of the article is that the screenshot is taken in Flash. You can do whatever you want with that image at that point.
CookieOfFortune
PHP will let you write that png to the server using a filestream. It's going to use the same mechanism within Flash to encode the .png data, then you just send the byte array to your PHP method.
Myk
A: 

Depending on the type of swf's you have you could try FFmpeg from the command line:

ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
cOle2
"[swf @ 0x9b822c0]Compressed SWF format not supported" - drat. Trying to Google a way out of this - apparently I should be able to build a tool that will decompress it...
Matchu
Interesting. Now PNG is listed as one of ffmpeg's formats, but I get "could not find codec parameters" anyway. I'll keep working on it.
Matchu
A: 

you can use swftools.
swfrender file.swf -o output.png

bhups
Odd. I had looked up swftools but somehow missed that particular tool that does exactly what I need. I'll check on that later today :)
Matchu
Seems to work instantly - and to think I already had this installed! Thanks!
Matchu