dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Introduce wgRelevantPageIsProbablyEditable"
[lhc/web/wiklou.git]
/
includes
/
media
/
GIFMetadataExtractor.php
diff --git
a/includes/media/GIFMetadataExtractor.php
b/includes/media/GIFMetadataExtractor.php
index
f5772de
..
b4c3d6e
100644
(file)
--- a/
includes/media/GIFMetadataExtractor.php
+++ b/
includes/media/GIFMetadataExtractor.php
@@
-54,15
+54,15
@@
class GIFMetadataExtractor {
* @return array
*/
static function getMetadata( $filename ) {
* @return array
*/
static function getMetadata( $filename ) {
- self::$gifFrameSep = pack( "C", ord( "," ) );
- self::$gifExtensionSep = pack( "C", ord( "!" ) );
- self::$gifTerm = pack( "C", ord( ";" ) );
+ self::$gifFrameSep = pack( "C", ord( "," ) );
// 2C
+ self::$gifExtensionSep = pack( "C", ord( "!" ) );
// 21
+ self::$gifTerm = pack( "C", ord( ";" ) );
// 3B
$frameCount = 0;
$duration = 0.0;
$isLooped = false;
$xmp = "";
$frameCount = 0;
$duration = 0.0;
$isLooped = false;
$xmp = "";
- $comment =
array()
;
+ $comment =
[]
;
if ( !$filename ) {
throw new Exception( "No file name specified" );
if ( !$filename ) {
throw new Exception( "No file name specified" );
@@
-82,8
+82,11
@@
class GIFMetadataExtractor {
throw new Exception( "Not a valid GIF file; header: $buf" );
}
throw new Exception( "Not a valid GIF file; header: $buf" );
}
- // Skip over width and height.
- fread( $fh, 4 );
+ // Read width and height.
+ $buf = fread( $fh, 2 );
+ $width = unpack( 'v', $buf )[1];
+ $buf = fread( $fh, 2 );
+ $height = unpack( 'v', $buf )[1];
// Read BPP
$buf = fread( $fh, 1 );
// Read BPP
$buf = fread( $fh, 1 );
@@
-118,8
+121,7
@@
class GIFMetadataExtractor {
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $extension_code = unpack( 'C', $buf );
- $extension_code = $extension_code[1];
+ $extension_code = unpack( 'C', $buf )[1];
if ( $extension_code == 0xF9 ) {
// Graphics Control Extension.
if ( $extension_code == 0xF9 ) {
// Graphics Control Extension.
@@
-131,8
+133,7
@@
class GIFMetadataExtractor {
if ( strlen( $buf ) < 2 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $buf ) < 2 ) {
throw new Exception( "Ran out of input" );
}
- $delay = unpack( 'v', $buf );
- $delay = $delay[1];
+ $delay = unpack( 'v', $buf )[1];
$duration += $delay * 0.01;
fread( $fh, 1 ); // Transparent colour index
$duration += $delay * 0.01;
fread( $fh, 1 ); // Transparent colour index
@@
-141,8
+142,7
@@
class GIFMetadataExtractor {
if ( strlen( $term ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $term ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $term = unpack( 'C', $term );
- $term = $term[1];
+ $term = unpack( 'C', $term )[1];
if ( $term != 0 ) {
throw new Exception( "Malformed Graphics Control Extension block" );
}
if ( $term != 0 ) {
throw new Exception( "Malformed Graphics Control Extension block" );
}
@@
-182,8
+182,7
@@
class GIFMetadataExtractor {
if ( strlen( $blockLength ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $blockLength ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $blockLength = unpack( 'C', $blockLength );
- $blockLength = $blockLength[1];
+ $blockLength = unpack( 'C', $blockLength )[1];
$data = fread( $fh, $blockLength );
if ( $blockLength != 11 ) {
$data = fread( $fh, $blockLength );
if ( $blockLength != 11 ) {
@@
-206,8
+205,7
@@
class GIFMetadataExtractor {
if ( strlen( $loopData ) < 2 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $loopData ) < 2 ) {
throw new Exception( "Ran out of input" );
}
- $loopData = unpack( 'v', $loopData );
- $loopCount = $loopData[1];
+ $loopCount = unpack( 'v', $loopData )[1];
if ( $loopCount != 1 ) {
$isLooped = true;
if ( $loopCount != 1 ) {
$isLooped = true;
@@
-245,19
+243,20
@@
class GIFMetadataExtractor {
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $byte = unpack( 'C', $buf );
- $byte = $byte[1];
+ $byte = unpack( 'C', $buf )[1];
throw new Exception( "At position: " . ftell( $fh ) . ", Unknown byte " . $byte );
}
}
throw new Exception( "At position: " . ftell( $fh ) . ", Unknown byte " . $byte );
}
}
- return
array(
+ return
[
'frameCount' => $frameCount,
'looped' => $isLooped,
'duration' => $duration,
'xmp' => $xmp,
'comment' => $comment,
'frameCount' => $frameCount,
'looped' => $isLooped,
'duration' => $duration,
'xmp' => $xmp,
'comment' => $comment,
- );
+ 'width' => $width,
+ 'height' => $height,
+ ];
}
/**
}
/**
@@
-283,8
+282,7
@@
class GIFMetadataExtractor {
if ( strlen( $data ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $data ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $buf = unpack( 'C', $data );
- $buf = $buf[1];
+ $buf = unpack( 'C', $data )[1];
$bpp = ( $buf & 7 ) + 1;
$buf >>= 7;
$bpp = ( $buf & 7 ) + 1;
$buf >>= 7;
@@
-303,8
+301,7
@@
class GIFMetadataExtractor {
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
if ( strlen( $buf ) < 1 ) {
throw new Exception( "Ran out of input" );
}
- $block_len = unpack( 'C', $buf );
- $block_len = $block_len[1];
+ $block_len = unpack( 'C', $buf )[1];
if ( $block_len == 0 ) {
return;
}
if ( $block_len == 0 ) {
return;
}