Merge "Ensure users are able to edit the page after changing the content model"
[lhc/web/wiklou.git] / includes / media / XCF.php
index f8fa252..108d6fb 100644 (file)
@@ -56,7 +56,7 @@ class XCFHandler extends BitmapHandler {
        /**
         * Get width and height from the XCF header.
         *
-        * @param File $image
+        * @param File|FSFile $image
         * @param string $filename
         * @return array
         */
@@ -68,21 +68,15 @@ class XCFHandler extends BitmapHandler {
 
                # Forge a return array containing metadata information just like getimagesize()
                # See PHP documentation at: http://www.php.net/getimagesize
-               $metadata = [];
-               $metadata[0] = $header['width'];
-               $metadata[1] = $header['height'];
-               $metadata[2] = null; # IMAGETYPE constant, none exist for XCF.
-               $metadata[3] = sprintf(
-                       'height="%s" width="%s"', $header['height'], $header['width']
-               );
-               $metadata['mime'] = 'image/x-xcf';
-               $metadata['channels'] = null;
-               $metadata['bits'] = 8; # Always 8-bits per color
-
-               assert( '7 == count($metadata); ' .
-                       '# return array must contains 7 elements just like getimagesize() return' );
-
-               return $metadata;
+               return [
+                       0 => $header['width'],
+                       1 => $header['height'],
+                       2 => null, # IMAGETYPE constant, none exist for XCF.
+                       3 => "height=\"{$header['height']}\" width=\"{$header['width']}\"",
+                       'mime' => 'image/x-xcf',
+                       'channels' => null,
+                       'bits' => 8, # Always 8-bits per color
+               ];
        }
 
        /**
@@ -155,13 +149,13 @@ class XCFHandler extends BitmapHandler {
         *
         * Greyscale files need different command line options.
         *
-        * @param File $file The image object, or false if there isn't one.
+        * @param File|FSFile $file The image object, or false if there isn't one.
         *   Warning, FSFile::getPropsFromPath might pass an (object)array() instead (!)
         * @param string $filename The filename
         * @return string
         */
        public function getMetadata( $file, $filename ) {
-               $header = self::getXCFMetadata( $filename );
+               $header = self::getXCFMetaData( $filename );
                $metadata = [];
                if ( $header ) {
                        // Try to be consistent with the names used by PNG files.