php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #37643 GetImageSize function can not determine size of Compressed Flash files (CWS)
Submitted: 2006-05-30 13:40 UTC Modified: 2006-06-01 12:52 UTC
From: vdv at bitrixsoft dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.4 OS: Any
Private report: No CVE-ID: None
 [2006-05-30 13:40 UTC] vdv at bitrixsoft dot com
Description:
------------
GetImageSize function can not determine size of Compressed Flash files (CWS).

Same as here:
http://bugs.php.net/bug.php?id=36542&edit=2
http://bugs.php.net/bug.php?id=34338&edit=2

This function still can not determine size and dimensions of the compressed Flash movies untill the Zlib library is compiled statically. But it can be quite easily done with manual decompressing file and reading its header.
So it need to be fixed in general case because of the Flash format popularity.

Reproduce code:
---------------
It can be reproduced with simple script that loads compressed Flash files and matches their sizes.

Expected result:
----------------
Here is quick solution based on some tips from your bug descriptions.


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

$tmpFilePath=$arFile."tmp";
$out=fopen($tmpFilePath, "w");
$in=fopen($arFile, "r");
fwrite($out,swf_decompress(fread($in, filesize($arFile))));
fclose($in);
fclose($out);
$arImageSize = getimagesize($tmpFilePath);
unlink($tmpFilePath);

Actual result:
--------------
Function returns false or error instead of actual size.
Interesting that this bug was added here in the year 2002 and it still can be reproduced easily. 
Do you have some special version that can not be downloaded by others? :)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-30 13:43 UTC] derick@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.


 [2006-06-01 12:52 UTC] vdv at bitrixsoft dot com
Ok. Changed to the Feature request. 
Really see many requests from our customers.
Do you have any plans on fixing the issue in the nearest time?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 21:01:33 2025 UTC