15

I've been given a Flash file (.swf extension) to put into a web page. Opening the file in my browser makes it quite blurry, so I'm assuming there is a natural size for the file, same as an image.

It's also rectangular so I need to work out the aspect ratio if I don't have an exact size. How would I find this information out?

DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
  • do you need to know this before embedding? – prodigitalson Dec 02 '09 at 15:27
  • It didn't work for me. I guess it's only valid for FLA's of a certain version. I found this class useful to some extent: http://www.phpclasses.org/package/1653-PHP-Parse-header-of-Flash-files-to-extract-metadata.html – arakno Oct 03 '12 at 11:42

4 Answers4

24

I was wondering how to get this myself last night. Didn't find anything on google, but then I remembered that PHP's getimagesize works on swf movies:

<?php
    $file = "YOUR_FILE.swf";
    $info = getimagesize($file);
    $width = $info[0];
    $height = $info[1];
    print "{$width}x{$height}\n";
?>
typeoneerror
  • 55,990
  • 32
  • 132
  • 223
7

After years I finally found a little tool that does exactly one thing: Displaying the height and width of a flash file. I cannot believe that Adobe never realized that knowing the size of a flash program is important.

Here you go: https://github.com/q2apro/swfinfo/raw/master/swfinfo.swf

I could not find the original source, please credit the developer if you know about. Thanks.

Avatar
  • 14,622
  • 9
  • 119
  • 198
3

I made script to detect dimensions of remote swf and print embed code of file.

http://www.igrice-tigrice.com/flash-dimensions.php

0
import zlib, lzma
def getswfdimension(fname):
    with open(fname, 'rb') as f:
        buf = f.read()
    sig = buf[:3].decode('ascii')
    d = None
    if sig == 'FWS':
        # uncompressed
        d = buf[8:]
    elif sig == 'CWS':
        d = zlib.decompress(buf[8:])
    elif sig == 'ZWS':
        d = lzma.decompress(buf[8:])
    if not d:
        print('unknown file format')
        return
    nbits = d[0]>>3
    bstr=''
    for i in range(32):
        bstr += '{:08b}'.format(d[i])
    bstr = bstr[5:]
    w = int( bstr[ nbits : 2*nbits], 2) # width in twips
    h = int (bstr[3*nbits: 4*nbits], 2)
    # width x height in pixel
    print("{} {} x {}".format(fname, int(w/20), int(h/20)))