3 * Handler for the Gimp's native file format
10 * Handler for the Gimp's native file format; getimagesize() doesn't
15 class XCFHandler
extends BitmapHandler
{
25 function getThumbType( $ext, $mime, $params = null ) {
26 return array( 'png', 'image/png' );
30 * Get width and height from the bmp header.
36 function getImageSize( $image, $filename ) {
37 return self
::getXCFMetaData( $filename );
40 static function getXCFMetaData( $filename ) {
41 global $wgImageMagickIdentifyCommand;
44 $cmd = wfEscapeShellArg( $wgImageMagickIdentifyCommand ) . ' -verbose ' . wfEscapeShellArg( $filename );
45 wfDebug( __METHOD__
. ": Running $cmd \n" );
47 $return = wfShellExec( $cmd, $retval );
50 $colorspace = preg_match_all( '/ *Colorspace: RGB/', $return, $match );
51 $frameCount = preg_match_all( '/ *Geometry: ([0-9]+x[0-9]+)\+[+0-9]*/', $return, $match );
52 wfDebug( __METHOD__
. ": Got $frameCount matches\n" );
54 /* if( $frameCount == 1 ) { */
55 /* preg_match( '/([0-9]+)x([0-9]+)/sm', $match[1][0], $m ); */
62 foreach( $match[1] as $res ) {
63 preg_match( '/([0-9]+)x([0-9]+)/sm', $res, $m );
64 if( $m[1] > $sizeX ) {
67 if( $m[2] > $sizeY ) {
73 wfDebug( __METHOD__
. ": Found $sizeX x $sizeY x $frameCount \n" );
74 $md['frameCount'] = $frameCount;
78 $md[3] = "height=\"$sizeY\" width=\"$sizeX\"";
79 $md['mime'] = 'image/x-xcf';
80 $md['channels'] = $colorspace == 1 ?
3 : 4;
86 * Must use "im" for XCF
90 protected static function getScalerType( $dstPath, $checkDstPath = true ) {