Index: trunk/phase3/includes/filerepo/file/File.php |
— | — | @@ -778,8 +778,11 @@ |
779 | 779 | wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE\n" ); |
780 | 780 | } |
781 | 781 | |
782 | | - // Create a temp FS file with the same extension |
783 | | - $tmpFile = TempFSFile::factory( 'transform_', $this->getExtension() ); |
| 782 | + // Create a temp FS file with the same extension and the thumbnail |
| 783 | + $extension = $this->getExtension(); |
| 784 | + list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( |
| 785 | + $extension, $this->getMimeType(), $params ); |
| 786 | + $tmpFile = TempFSFile::factory( 'transform_', $this->getExtension() . '.' . $thumbExt ); |
784 | 787 | if ( !$tmpFile ) { |
785 | 788 | return new MediaTransformError( 'thumbnail_error', |
786 | 789 | $params['width'], 0, wfMsg( 'thumbnail-temp-create' ) ); |
Index: trunk/phase3/includes/media/Bitmap.php |
— | — | @@ -302,6 +302,8 @@ |
303 | 303 | $animation_post = '-fuzz 5% -layers optimizeTransparency'; |
304 | 304 | } |
305 | 305 | } |
| 306 | + } elseif ( $params['mimeType'] == 'image/x-xcf' ) { |
| 307 | + $animation_post = '-layers merge'; |
306 | 308 | } |
307 | 309 | |
308 | 310 | // Use one thread only, to avoid deadlock bugs on OOM |
Index: trunk/phase3/includes/media/XCF.php |
— | — | @@ -0,0 +1,93 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Handler for Microsoft's bitmap format |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Media |
| 8 | + */ |
| 9 | + |
| 10 | +/** |
| 11 | + * Handler for Microsoft's bitmap format; getimagesize() doesn't |
| 12 | + * support these files |
| 13 | + * |
| 14 | + * @ingroup Media |
| 15 | + */ |
| 16 | +class XCFHandler extends BitmapHandler { |
| 17 | + |
| 18 | + /** |
| 19 | + * Render files as PNG |
| 20 | + * |
| 21 | + * @param $ext |
| 22 | + * @param $mime |
| 23 | + * @param $params |
| 24 | + * @return array |
| 25 | + */ |
| 26 | + function getThumbType( $ext, $mime, $params = null ) { |
| 27 | + return array( 'png', 'image/png' ); |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Get width and height from the bmp header. |
| 32 | + * |
| 33 | + * @param $image |
| 34 | + * @param $filename |
| 35 | + * @return array |
| 36 | + */ |
| 37 | + function getImageSize( $image, $filename ) { |
| 38 | + return self::getXCFMetaData( $filename ); |
| 39 | + } |
| 40 | + |
| 41 | + static function getXCFMetaData( $filename ) { |
| 42 | + global $wgImageMagickIdentifyCommand; |
| 43 | + |
| 44 | + $md = false; |
| 45 | + $cmd = wfEscapeShellArg( $wgImageMagickIdentifyCommand ) . ' -verbose ' . wfEscapeShellArg( $filename ); |
| 46 | + wfDebug( __METHOD__ . ": Running $cmd \n" ); |
| 47 | + $retval = ''; |
| 48 | + $return = wfShellExec( $cmd, $retval ); |
| 49 | + |
| 50 | + if( $retval == 0 ) { |
| 51 | + $colorspace = preg_match_all( '/ *Colorspace: RGB/', $return, $match ); |
| 52 | + $frameCount = preg_match_all( '/ *Geometry: ([0-9]+x[0-9]+)\+[+0-9]*/', $return, $match ); |
| 53 | + wfDebug( __METHOD__ . ": Got $frameCount matches\n" ); |
| 54 | + |
| 55 | + /* if( $frameCount == 1 ) { */ |
| 56 | + /* preg_match( '/([0-9]+)x([0-9]+)/sm', $match[1][0], $m ); */ |
| 57 | + /* $sizeX = $m[1]; */ |
| 58 | + /* $sizeY = $m[2]; */ |
| 59 | + /* } else { */ |
| 60 | + $sizeX = 0; |
| 61 | + $sizeY = 0; |
| 62 | + |
| 63 | + foreach( $match[1] as $res ) { |
| 64 | + preg_match( '/([0-9]+)x([0-9]+)/sm', $res, $m ); |
| 65 | + if( $m[1] > $sizeX ) { |
| 66 | + $sizeX = $m[1]; |
| 67 | + } |
| 68 | + if( $m[2] > $sizeY ) { |
| 69 | + $sizeY = $m[2]; |
| 70 | + } |
| 71 | + } |
| 72 | + /* } */ |
| 73 | + |
| 74 | + wfDebug( __METHOD__ . ": Found $sizeX x $sizeY x $frameCount \n" ); |
| 75 | + $md['frameCount'] = $frameCount; |
| 76 | + $md[0] = $sizeX; |
| 77 | + $md[1] = $sizeY; |
| 78 | + $md[2] = null; |
| 79 | + $md[3] = "height=\"$sizeY\" width=\"$sizeX\""; |
| 80 | + $md['mime'] = 'image/x-xcf'; |
| 81 | + $md['channels'] = $colorspace == 1 ? 3 : 4; |
| 82 | + } |
| 83 | + return $md; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Must use "im" for XCF |
| 88 | + * |
| 89 | + * @return string |
| 90 | + */ |
| 91 | + protected static function getScalerType( $dstPath, $checkDstPath = true ) { |
| 92 | + return "im"; |
| 93 | + } |
| 94 | +} |
Property changes on: trunk/phase3/includes/media/XCF.php |
___________________________________________________________________ |
Added: svn:eol-syle |
1 | 95 | + native |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -620,6 +620,7 @@ |
621 | 621 | 'image/tiff' => 'TiffHandler', |
622 | 622 | 'image/x-ms-bmp' => 'BmpHandler', |
623 | 623 | 'image/x-bmp' => 'BmpHandler', |
| 624 | + 'image/x-xcf' => 'XCFHandler', |
624 | 625 | 'image/svg+xml' => 'SvgHandler', // official |
625 | 626 | 'image/svg' => 'SvgHandler', // compat |
626 | 627 | 'image/vnd.djvu' => 'DjVuHandler', // official |
— | — | @@ -638,6 +639,8 @@ |
639 | 640 | $wgUseImageMagick = false; |
640 | 641 | /** The convert command shipped with ImageMagick */ |
641 | 642 | $wgImageMagickConvertCommand = '/usr/bin/convert'; |
| 643 | +/** The identify command shipped with ImageMagick */ |
| 644 | +$wgImageMagickIdentifyCommand = '/usr/bin/identify'; |
642 | 645 | |
643 | 646 | /** Sharpening parameter to ImageMagick */ |
644 | 647 | $wgSharpenParameter = '0x0.4'; |