note 76825 added to ref.ming
| From: | random at nowhere dot com | Date: | Wed, 01 Aug 2007 08:48:48 +0000 |
| Subject: | note 76825 added to ref.ming | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129096@lists.php.net to get a copy of this message | ||
For those looking for just getting size of a .swf file :
<?
// bytes_to_signed_int(data,offset,length)
function b2i($d,$o,$l) {
$s=(ord($d[$o/8])>>(7-$o%8))&1; $r=0;
for ($i=$o+1;$i<$o+$l;$i++) {
$b=(ord($d[$i/8])>>(7-$i%8))&1;
$r=($r<<1)+($s?!$b:$b);
}
if ($s) { $r++; $r=-$r; }
return $r;
}
// flash9 or <9 but uncompressed
$f="myfile.swf";
// get only 20 first bytes
$d=file_get_contents($f,0,null,0,20);
echo "Version of Flash : ".ord($d[3])."<br>";
$s=unpack("V",substr($d,4,4)); echo "FileSize : ".$s[1]."
bytes<br>";
// here is the decompression, fix this for flash <9
if (substr($d,0,3)=="CWS") $d=substr($d,0,8).gzinflate(substr($d,8));
$nb=ord($d[8])>>3; // bytes needed
$xmin=b2i($d,8*8+5,$nb);
$xmax=b2i($d,8*8+5+$nb,$nb);
$ymin=b2i($d,8*8+5+2*$nb,$nb);
$ymax=b2i($d,8*8+5+3*$nb,$nb);
// width=xmax-xmin, height=ymax-ymin, twips->pixels = /20
echo "width=".(($xmax-$xmin)/20)."<br>";
echo "height=".(($ymax-$ymin)/20)."<br>";
?>
----
Server IP: 194.153.94.10
Probable Submitter: 81.13.205.84
----
Manual Page -- http://www.php.net/manual/en/ref.ming.php
Edit -- https://master.php.net/note/edit/76825
Del: integrated -- https://master.php.net/note/delete/76825/integrated
Del: useless -- https://master.php.net/note/delete/76825/useless
Del: bad code -- https://master.php.net/note/delete/76825/bad+code
Del: spam -- https://master.php.net/note/delete/76825/spam
Del: non-english -- https://master.php.net/note/delete/76825/non-english
Del: in docs -- https://master.php.net/note/delete/76825/in+docs
Del: other reasons-- https://master.php.net/note/delete/76825
Reject -- https://master.php.net/note/reject/76825
Search -- https://master.php.net/manage/user-notes.php