Cleanup debug and comments of r68324
This commit is contained in:
parent
bcd3dd1943
commit
c66050d9e3
1 changed files with 9 additions and 9 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PNG frame counter.
|
* PNG frame counter.
|
||||||
* Based on
|
* Slightly derived from GIFMetadataExtractor.php
|
||||||
* Deliberately not using MWExceptions to avoid external dependencies, encouraging
|
* Deliberately not using MWExceptions to avoid external dependencies, encouraging
|
||||||
* redistribution.
|
* redistribution.
|
||||||
*/
|
*/
|
||||||
|
|
@ -19,41 +19,41 @@ class PNGMetadataExtractor {
|
||||||
$duration = 0.0;
|
$duration = 0.0;
|
||||||
|
|
||||||
if (!$filename)
|
if (!$filename)
|
||||||
throw new Exception( __METHOD__ . "No file name specified" );
|
throw new Exception( __METHOD__ . ": No file name specified" );
|
||||||
elseif ( !file_exists($filename) || is_dir($filename) )
|
elseif ( !file_exists($filename) || is_dir($filename) )
|
||||||
throw new Exception( __METHOD__ . "File $filename does not exist" );
|
throw new Exception( __METHOD__ . ": File $filename does not exist" );
|
||||||
|
|
||||||
$fh = fopen( $filename, 'r' );
|
$fh = fopen( $filename, 'r' );
|
||||||
|
|
||||||
if (!$fh)
|
if (!$fh)
|
||||||
throw new Exception( __METHOD__ . "Unable to open file $filename" );
|
throw new Exception( __METHOD__ . ": Unable to open file $filename" );
|
||||||
|
|
||||||
// Check for the PNG header
|
// Check for the PNG header
|
||||||
$buf = fread( $fh, 8 );
|
$buf = fread( $fh, 8 );
|
||||||
if ( !($buf == self::$png_sig) ) {
|
if ( !($buf == self::$png_sig) ) {
|
||||||
throw new Exception( __METHOD__ . "Not a valid PNG file; header: $buf" );
|
throw new Exception( __METHOD__ . ": Not a valid PNG file; header: $buf" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read chunks
|
// Read chunks
|
||||||
while( !feof( $fh ) ) {
|
while( !feof( $fh ) ) {
|
||||||
$buf = fread( $fh, 4 );
|
$buf = fread( $fh, 4 );
|
||||||
if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; }
|
if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; }
|
||||||
$chunk_size = unpack( "N", $buf);
|
$chunk_size = unpack( "N", $buf);
|
||||||
$chunk_size = $chunk_size[1];
|
$chunk_size = $chunk_size[1];
|
||||||
|
|
||||||
$chunk_type = fread( $fh, 4 );
|
$chunk_type = fread( $fh, 4 );
|
||||||
if( !$chunk_type ) { throw new Exception( __METHOD__ . "Read error" ); return; }
|
if( !$chunk_type ) { throw new Exception( __METHOD__ . ": Read error" ); return; }
|
||||||
|
|
||||||
if ( $chunk_type == "acTL" ) {
|
if ( $chunk_type == "acTL" ) {
|
||||||
$buf = fread( $fh, $chunk_size );
|
$buf = fread( $fh, $chunk_size );
|
||||||
if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; }
|
if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; }
|
||||||
|
|
||||||
$actl = unpack( "Nframes/Nplays", $buf );
|
$actl = unpack( "Nframes/Nplays", $buf );
|
||||||
$frameCount = $actl['frames'];
|
$frameCount = $actl['frames'];
|
||||||
$loopCount = $actl['plays'];
|
$loopCount = $actl['plays'];
|
||||||
} elseif ( $chunk_type == "fcTL" ) {
|
} elseif ( $chunk_type == "fcTL" ) {
|
||||||
$buf = fread( $fh, $chunk_size );
|
$buf = fread( $fh, $chunk_size );
|
||||||
if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; }
|
if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; }
|
||||||
$buf = substr( $buf, 20 );
|
$buf = substr( $buf, 20 );
|
||||||
|
|
||||||
$fctldur = unpack( "ndelay_num/ndelay_den", $buf );
|
$fctldur = unpack( "ndelay_num/ndelay_den", $buf );
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue