From: Derk-Jan Hartman Date: Fri, 20 Aug 2010 13:22:02 +0000 (+0000) Subject: Add getMagickVersion(). Will use this to provide optimization of animated gifs. X-Git-Tag: 1.31.0-rc.0~35432 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=5a8ff385de14535a338117608edd6491edf5bdf3;p=lhc%2Fweb%2Fwiklou.git Add getMagickVersion(). Will use this to provide optimization of animated gifs. --- diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 170c0c5455..01745be0c1 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -340,6 +340,32 @@ class BitmapHandler extends ImageHandler { return $path; } + /** + * Retrieve the version of the installed ImageMagick + * You can use PHPs version_compare() to use this value + * Value is cached for one hour. + * @return String representing the IM version. + */ + protected function getMagickVersion() { + global $wgMemc; + + $cache = $wgMemc->get( "imagemagick-version" ); + if( !$cache ) { + global $wgImageMagickConvertCommand; + $cmd = wfEscapeShellArg( $wgImageMagickConvertCommand ) . ' -version'; + wfDebug( __METHOD__.": Running convert -version\n" ); + $return = wfShellExec( $cmd, $retval ); + $x = preg_match('/Version: ImageMagick ([0-9]*\.[0-9]*\.[0-9]*)/', $return, $matches); + if( $x != 1 ) { + wfDebug( __METHOD__.": ImageMagick version check failed\n" ); + return null; + } + $wgMemc->set( "imagemagick-version", $matches[1], 3600 ); + return $matches[1]; + } + return $cache; + } + static function imageJpegWrapper( $dst_image, $thumbPath ) { imageinterlace( $dst_image ); imagejpeg( $dst_image, $thumbPath, 95 );