php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17272 Failure to read Flash MX file size
Submitted: 2002-05-16 12:00 UTC Modified: 2002-05-23 17:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: zzz123123123 at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.2 OS: N/A
Private report: No CVE-ID: None
 [2002-05-16 12:00 UTC] zzz123123123 at hotmail dot com
Flash file size detection seems to not work for Flash files published in the new Flash "MX" (version 6).  When published to version 5 or lower, it works.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-16 12:22 UTC] reywob at f2s dot com
The problem is with the getimagesize() function and its detection routines which don't detect Flash 6/MX content.
 [2002-05-16 13:22 UTC] derick@php.net
Not really a bug, as it was not written for this :)
Anyway, if you could mail me  empty flash movies with the following size, I'll see what I can do:

255x127
640x480
400x256
(and perhaps some more)

Derick
 [2002-05-17 13:27 UTC] derick@php.net
I'm suspending this until somebody can show me some documentation on the new fileformat. Apperently there are two Flash 6 formats, the SWF one (which works fine and is the same as Flash 5) and the SWC one, which is some compressed format.

Derick
 [2002-05-23 08:40 UTC] niels at creatype dot nl
I ran into the same problem when Flash 6 came out, so I tried to fix the problem with PHP code. The SWC format is a regular SWF file, but with a portion of the file compressed with zlib. Unfortunately the width and height of the SWC file is located inside the compressed portion.

SWF:
[HEADER - 3 bytes] 'FWS'
[VERSION - 1 byte] In which version was this file created
[SIZE - 4 bytes]   size of file
[TAGS]             All tags

SWC:
[HEADER - 3 bytes] 'CWS'
[VERSION - 1 byte] In which version was this file created
[SIZE - 4 bytes]   size of uncompressed file
[ZLIBSTREAM]       Zlib compressed stream of all tags

To decompress the file you need to copy the first 8 bytes of the SWC file to a buffer and change to first byte of the buffer to 'C'. Then you need to decompress the remaining bytes of the SWC file and append it to the buffer.


The following PHP function uses this method to decompress the file:

function phpAds_SWFDecompress($buffer)
{
  if (function_exists('gzuncompress') &&
    substr($buffer, 0, 3) == swf_tag_compressed &&
    ord(substr($buffer, 3, 1)) >= 6)
  {
    $output  = 'F';
    $output .= substr ($buffer, 1, 7);
    $output .= gzuncompress (substr ($buffer, 8));
		
    return ($output);
  }
  else
    return ($buffer);
}

If you are only interested in retrieving the dimensions of the SWC file it can be even easier. Just strip the first 8 bytes of the SWC file and decompress the remaining bytes. The tags for the width and height should be first two tags inside the decompressed stream.
 [2002-05-23 08:43 UTC] derick@php.net
This is enough info.. I'll see if I can hack it in.

Derick
 [2002-05-23 17:46 UTC] derick@php.net
Added code to handle compressed SWF files to CVS, please try the latest snapshot (in a couple of hours from now) from http://snaps.php.net/

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC