hexagonit.swfheader is a Python library that provides a single function -- parse -- that is able to parse the metadata in a SWF (Flash animation) file. The main use case is to interrogate the dimensions of a SWF file to help in embedding the file in a HTML page.
Using the parser is very simple, simply call the hexagonit.swfheader.parse function and call it with either a filesystem path or a file-like object.
>>> import hexagonit.swfheader
>>> metadata = hexagonit.swfheader.parse(TEST_SWF)
The parse function returns a dictionary that contains the following items:
The version of the Flash format, e.g. 7.
True, if the contents of the file are compressed using zlib compression, False otherwise.
Byte size of the (uncompressed) contents of the SWF file.
The lesser x-coordinate of the bounding rectangle of the contents.
The greater x-coordinate of the bounding rectangle of the contents.
The lesser y-coordinate of the bounding rectangle of the contents.
The greater y-coordinate of the bounding rectangle of the contents.
The width of the SWF file in pixels.
The height of the SWF file in pixels.
The number of frames in the SWF file.
Frames per second.
When installed with setuptools a script named swfheader is placed in your bin directory which can be used to easily introspect SWF files on the filesystem:
$ swfheader some_file.swf
Dimensions: 1105 x 1629
Bounding box: (0, 1105, 0, 1629)
What's New in This Release: [ read full changelog ]
· Only close file handles explicitly opened by the parser itself. Fixes an issue where file handles that were passed in as parameters were prematurely closed. See https://github.com/dokai/hexagonit-swfheader/pull/1 [aleksandr-rakov]