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

后端 未结 3 1902
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-09 05:20

I would like to write a python script that takes a bunch of swf files and renders them to individual image files.

Each swf file has just one frame (text, pictures etc.)

相关标签:
3条回答
  • 2021-02-09 06:14

    Sometimes SWFRender is stuck at very heavy files, especially when producing 300dpi+ images. In this case Gnash may help:

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

    here we dump a last frame of a movie to file output.png disabling sound processing and exiting after the frame is rendered. Also we can specify the scale factor here or use

    -j width -k height
    

    to specify the exact size of resulting image.

    0 讨论(0)
  • 2021-02-09 06:20

    You could for example build an AIR app that loads each SWF, takes the screenshot and writes it to a file.

    The thing is you'll need to kick off something to do the render and, as far as i know, you can't do that without the player or some of its Open Source implementation.

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

    HTH,

    J

    0 讨论(0)
  • 2021-02-09 06:24

    I'm sorry to answer my own question, but I found an undocumented feature of swfrender (part of the swftools) by browsing through 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 lets you determine the width (in pixels) of the output and Y does the same for the height. If you just set one parameter, then the other one is chosen in relation to the original height-width-ratio (pretty useful)

    That does the trick for me but as Zarate offered a solution that might be even better (I'm thinking of swf to PDF conversion) he deserves the credits.

    Cheers

    0 讨论(0)
提交回复
热议问题