X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fmedia%2FPNGMetadataExtractor.php;h=1cb2ec019aa3222154f3eb8074b7d0f995d830b9;hb=853b17ef5788be25045855ab340c9e0d8b443218;hp=f4f29dd1fb2344cb7ed444f9a254d2a662055c0b;hpb=2f885ee6b797e5a176ce7b270b674a04b5945b06;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/PNGMetadataExtractor.php b/includes/media/PNGMetadataExtractor.php index f4f29dd1fb..1cb2ec019a 100644 --- a/includes/media/PNGMetadataExtractor.php +++ b/includes/media/PNGMetadataExtractor.php @@ -47,7 +47,7 @@ class PNGMetadataExtractor { self::$pngSig = pack( "C8", 137, 80, 78, 71, 13, 10, 26, 10 ); self::$crcSize = 4; /* based on list at http://owl.phy.queensu.ca/~phil/exiftool/TagNames/PNG.html#TextualData - * and http://www.w3.org/TR/PNG/#11keywords + * and https://www.w3.org/TR/PNG/#11keywords */ self::$textChunks = [ 'xml:com.adobe.xmp' => 'xmp', @@ -121,9 +121,11 @@ class PNGMetadataExtractor { if ( !$buf || strlen( $buf ) < $chunk_size ) { throw new Exception( __METHOD__ . ": Read error" ); } + $width = unpack( 'N', substr( $buf, 0, 4 ) )[1]; + $height = unpack( 'N', substr( $buf, 4, 4 ) )[1]; $bitDepth = ord( substr( $buf, 8, 1 ) ); // Detect the color type in British English as per the spec - // http://www.w3.org/TR/PNG/#11IHDR + // https://www.w3.org/TR/PNG/#11IHDR switch ( ord( substr( $buf, 9, 1 ) ) ) { case 0: $colorType = 'greyscale'; @@ -404,6 +406,8 @@ class PNGMetadataExtractor { 'text' => $text, 'bitDepth' => $bitDepth, 'colorType' => $colorType, + 'width' => $width, + 'height' => $height, ]; }