|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
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.