From 5a8ff385de14535a338117608edd6491edf5bdf3 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Fri, 20 Aug 2010 13:22:02 +0000 Subject: [PATCH] Add getMagickVersion(). Will use this to provide optimization of animated gifs. --- includes/media/Bitmap.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 ); -- 2.20.1