Index: branches/img_metadata/phase3/includes/media/PNGMetadataExtractor.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * PNG frame counter. |
5 | | - * Based on |
| 5 | + * Slightly derived from GIFMetadataExtractor.php |
6 | 6 | * Deliberately not using MWExceptions to avoid external dependencies, encouraging |
7 | 7 | * redistribution. |
8 | 8 | */ |
— | — | @@ -19,41 +19,41 @@ |
20 | 20 | $duration = 0.0; |
21 | 21 | |
22 | 22 | if (!$filename) |
23 | | - throw new Exception( __METHOD__ . "No file name specified" ); |
| 23 | + throw new Exception( __METHOD__ . ": No file name specified" ); |
24 | 24 | elseif ( !file_exists($filename) || is_dir($filename) ) |
25 | | - throw new Exception( __METHOD__ . "File $filename does not exist" ); |
| 25 | + throw new Exception( __METHOD__ . ": File $filename does not exist" ); |
26 | 26 | |
27 | 27 | $fh = fopen( $filename, 'r' ); |
28 | 28 | |
29 | 29 | if (!$fh) |
30 | | - throw new Exception( __METHOD__ . "Unable to open file $filename" ); |
| 30 | + throw new Exception( __METHOD__ . ": Unable to open file $filename" ); |
31 | 31 | |
32 | 32 | // Check for the PNG header |
33 | 33 | $buf = fread( $fh, 8 ); |
34 | 34 | if ( !($buf == self::$png_sig) ) { |
35 | | - throw new Exception( __METHOD__ . "Not a valid PNG file; header: $buf" ); |
| 35 | + throw new Exception( __METHOD__ . ": Not a valid PNG file; header: $buf" ); |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Read chunks |
39 | 39 | while( !feof( $fh ) ) { |
40 | 40 | $buf = fread( $fh, 4 ); |
41 | | - if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; } |
| 41 | + if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } |
42 | 42 | $chunk_size = unpack( "N", $buf); |
43 | 43 | $chunk_size = $chunk_size[1]; |
44 | 44 | |
45 | 45 | $chunk_type = fread( $fh, 4 ); |
46 | | - if( !$chunk_type ) { throw new Exception( __METHOD__ . "Read error" ); return; } |
| 46 | + if( !$chunk_type ) { throw new Exception( __METHOD__ . ": Read error" ); return; } |
47 | 47 | |
48 | 48 | if ( $chunk_type == "acTL" ) { |
49 | 49 | $buf = fread( $fh, $chunk_size ); |
50 | | - if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; } |
| 50 | + if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } |
51 | 51 | |
52 | 52 | $actl = unpack( "Nframes/Nplays", $buf ); |
53 | 53 | $frameCount = $actl['frames']; |
54 | 54 | $loopCount = $actl['plays']; |
55 | 55 | } elseif ( $chunk_type == "fcTL" ) { |
56 | 56 | $buf = fread( $fh, $chunk_size ); |
57 | | - if( !$buf ) { throw new Exception( __METHOD__ . "Read error" ); return; } |
| 57 | + if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } |
58 | 58 | $buf = substr( $buf, 20 ); |
59 | 59 | |
60 | 60 | $fctldur = unpack( "ndelay_num/ndelay_den", $buf ); |