How do I find the natural size/dimensions of a Flash SWF file?
Asked Answered
B

4

14

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?

Basilicata answered 2/12, 2009 at 15:10 Comment(2)
do you need to know this before embedding?Couplet
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: phpclasses.org/package/…Cowardice
B
23

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";
?>
Bipartite answered 2/12, 2009 at 16:26 Comment(0)
M
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.

Mildred answered 16/5, 2014 at 17:48 Comment(0)
D
3

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

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

Dannielledannon answered 13/9, 2013 at 13:39 Comment(0)
A
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)))
Ashlan answered 26/6, 2019 at 2:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.