I'm considering hexagonit, and swfTools. Does anyone have any other solutions, or insight? Edit:
New Question - how to solve this error: I tried using hexagonit.swfheader however I receive the error:
f = 'out/'+w+"/"+s+"/"+"theSwf/"+s data = hexagonit.swfheader.parse(f) File "/Library/Python/2.7/site-packages/hexagonit/swfheader/__init__.py", line 26, in parse signature = ''.join(struct.unpack('<3c', input.read(3))) struct.error: unpack requires a string argument of length 3
After tracing through this I found that the error occurs here:
def parse(input): """Parses the header information from an SWF file.""" need_close=False if hasattr(input, 'read'): input.seek(0) else: input = open(input, 'rb')* need_close=True<h2>* being where the error occurs.</h2>
I read: <a href="https://stackoverflow.com/questions/5136317/get-dimensions-from-a-flash-file-swf-in-pure-python" rel="nofollow">Get dimensions from a flash file (.swf) in pure-Python</a>
I have also tried using PIL and Pillow however I am under the impression that they compare images not swf files. I decompiled the swf file's I'm looking at along but also have the swf file itself.
I would like to know what size the file displays as (dimensions).
My first thought was to try using image size comparison.<blockquote>
My issue with this is that some images that are used as assets in the swf are actually larger than the swf itself, otherwise I would use PIL to simply get the dimensions of the largest image asset (ex the background).
Secondly my other issue is that can equally compare svg and png files.. and Pillow and Pil to my knowledge do not handle svg files.</blockquote>
My second idea was to search the actionscript code for the dimensions.<blockquote>
Some files have in their action script something like 300x300 which denotes the size. Unfortunately after looking at most of the files I am working with do not which means this is largely unhelpful.</blockquote>
My 3rd idea was to ignore the decompiled swf data and rather focus on the swf itself.<blockquote>
I could in theory either try to find the dimensions in the byte code (or use a library that does this (which I need to find one as pip and pillow do not appear to work)) or I need to run the ad and then screenshot it and try to find where the ad starts and stops and calculate the pixels based on that. My problem with screens shotting it is that the image may blend into the background and make it hard if not impossible to get the correct dimensions, but more importantly many swfs cannot be played due to security if they are not played in the right url, etc.</blockquote>
Thus I'm left with a dilemma. I think the best way to go about this would be to use the swf file itself.Answer1:
Take a look at the official <a href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf" rel="nofollow">SWF file format spec</a>. The dimension info you are looking for should be right near the beginning of the file. Take a look at the section "The SWF header"
The FrameSize field defines the width and height of the on-screen display. This field is stored as a RECT structure, meaning that its size may vary according to the number of bits needed to encode the coordinates. The FrameSize RECT always has Xmin and Ymin value of 0; the Xmax and Ymax members define the width and height (see Using bit values).