Render Flash (SWF) as image (PDF, PNG, JPG)

I would like to write a python script that takes a bunch of swf files and maps them into separate image files.

Each swf file has only one frame (text, images, etc.) and no animations at all. I already tried the render command from the swftools toolkit (Windows version), but the resolution of the resulting image is too low.

So what I need:

A command line tool (Windows / Linux) or a python library that maps a single frame from swf to a bitmap or better for something like PDF (it would be great if the text data could be saved). It would be great if the target resolution / size could be set manually.

Thanks in advance!

+7
command-line flash
source share
3 answers

You can, for example, create an AIR application that loads each SWF, takes a screenshot and writes it to a file.

The fact is that you will need to do something for rendering, and as far as I know, you cannot do this without a player or any open source implementation of it.

I think your best bet is AIR, the SDK is free and cross-platform. If you are used to python, the required AS3 should be simple enough to pick up.

NTN

J

+3
source share

Sorry to answer your question, but found the undocumented swfrender function (part of swftools) by looking at the sources.

swfrender path/to/my.swf -X<width of output> -Y<height of output> -o<filename of output png> 

As you might have guessed, the X option allows you to specify the width (in pixels) of the output, and Y is the same for the height. If you just set one parameter, then the other is selected relative to the original ratio of height and width (quite useful)

This does the trick for me, but since Zarate offered a solution that might be even better (I think of swf to PDF conversion), it deserves credit.

Greetings

+11
source share

Sometimes SWFRender gets stuck in very heavy files, especially when creating images with a resolution of 300 dpi. In this case, Gnash can help:

 gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf 

here we upload the last frame of the movie to the output.png file, turn off sound processing and exit after rendering the frame. You can also specify a scale factor here or use

 -j width -k height 

to indicate the exact size of the resulting image.

+5
source share

All Articles