Is there a way to use a server-side script to get the height and width of a flash movie's stage?
September 22, 2004 7:00 AM   Subscribe

Does anyone know if there's a way to pull the height and width of a flash movie's stage out of an SWF using PHP/Perl or some other server side script? Is that information even stored in the swf files, or do "the vectors" make it irrelevant?

I want to get information about an existing SWF, not create new ones, so things like freemovie don't help. (Unless they do)
posted by alan to Computers & Internet (10 answers total)
 
Have you tried a Flash decompiler? I've never needed one, but I've heard of 'em. Supposedly they can take an .swf file and output a .fla file.
posted by planetkyoto at 7:53 AM on September 22, 2004


It's been a long time since I've done anything with Flash, and Flash itself has changed somewhat since I last used it, but I don't believe there is any such concept as a "height" and "width" in Flash. Certainly the dinky little Flash game I stole from some site becomes playable in full size when loaded all by itself in a browser.

At the very least, most Flash, if not all of it, seems to ignore the concept of size or aspect ratio. Maybe someone with a hell of a lot more experience with the thing will come along and clarify.
posted by majick at 7:56 AM on September 22, 2004


majick, flash files do have an intrinsic height and width, it's just that the player lets you resize them. Dreamweaver, for example, can 'read' the original height and width of a .swf file.

I don't know how to read it from php/perl, alas.
posted by signal at 8:31 AM on September 22, 2004


Planetkyoko: He mentioned that he wanted something in PHP or Perl, so I don't think those apply.

I though majick was right. Since flash is vector graphics, I figured there would be no set width/height in the file. You specify in the HTML embed tag the height/width you want it to display as in the browser.

Although, now that I am thinking a bit more, I think you can set a default size in the file itself... which seems to be confirmed here.

This should get the job done. This looks useful too.
posted by mrgavins at 8:33 AM on September 22, 2004


M. gavine, thank you. The SWF module for PHP wasn't an option because I wanted something that's Win/*nix portable and commonly installed. I had no idea that the imagesize function could handle SWF's as well (live and learn), but this might be a problem

This will not work for swf files unless zlib is compiled into php statically (not as a shared module). Bug #29611

However, that class on Zend looks perfect. Hooray for Ask Metafilter, with has atrophied my search-fu.
posted by alan at 8:51 AM on September 22, 2004


I believe this perl script is what you're looking for. Should be totally portable.

http://www.flashkit.com/board/showthread.php?threadid=296812
posted by derbs at 9:19 AM on September 22, 2004


Actually, if you were looking for a homegrown solution. You could have Flash call a Javascript function via getURL(javacsript:someFunc);
That would allow the movie to set the size and refresh the page.

However, you might be better having a flash movie that's your maximum size load other flash movies and size them accordingly. There's a lot of easier things to do with sizing from within the flash movie.
posted by lumpenprole at 10:54 AM on September 22, 2004


Gaaaaaaaaaaaaaaah, the Zend class requires Zlib as well. On to perl.
posted by alan at 11:41 AM on September 22, 2004


Depending on your comfort level with PHP, you could remove the zlib dependency from the Zend class by editing out the code having to do with handling compressed files.
posted by sad_otter at 3:11 PM on September 22, 2004


Sad_otter, then I'd loose the ability to read compressed SWFs, which is unacceptable to what I'm trying to accomplish, (but again, thanks for the creative thinking).

The linked perl script worked on some of my SWF's, but not others. After a bit of tinkering with the binary file in a text editor and reading up a bit more on where stuff is located, I realized that the perl script was failing on any file that was compressed. It wasn't even aware there could be compressed files. So that went right out (plus it didn't "use strict", and I don't want Mr. Wall to come beat me up).

It appears the only thing you can read from a compressed SWF is its version (and whether or not it's compressed). To get at anything else you need to decompress the file, which is why all of the other options needed zlib.

All that means that (easily) writing the script I wanted in a "portable/multi-platform/yourhostingsetupsucks" way isn't possible. Feh.
posted by alan at 5:30 PM on September 22, 2004


« Older Booker Prize Books   |   Big Beetles Newer »
This thread is closed to new comments.