diff --git a/conlite/includes/functions.api.images.php b/conlite/includes/functions.api.images.php index a0a8b0d..4f7774d 100644 --- a/conlite/includes/functions.api.images.php +++ b/conlite/includes/functions.api.images.php @@ -516,12 +516,14 @@ function capiImgScaleImageMagick($img, $maxX, $maxY, $crop = false, $expand = fa } /* Try to execute convert */ - $output = array(); - $retVal = 0; - if ($crop) { - exec("convert -gravity center -quality " . $quality . " -crop {$maxX}x{$maxY}+1+1 \"$filename\" $cacheFile", $output, $retVal); - } else { - exec("convert -quality " . $quality . " -geometry {$targetX}x{$targetY} \"$filename\" $cacheFile", $output, $retVal); + if (function_exists("exec")) { + $output = array(); + $retVal = 0; + if ($crop) { + exec("convert -gravity center -quality " . $quality . " -crop {$maxX}x{$maxY}+1+1 \"$filename\" $cacheFile", $output, $retVal); + } else { + exec("convert -quality " . $quality . " -geometry {$targetX}x{$targetY} \"$filename\" $cacheFile", $output, $retVal); + } } if (!file_exists($cacheFile)) { @@ -539,6 +541,25 @@ function capiImgScaleImageMagick($img, $maxX, $maxY, $crop = false, $expand = fa * @return boolean true (gif is animated)/ false (single frame gif) */ function isAnimGif($sFile) { + if(!($fh = @fopen($sFile, 'rb'))) + return false; + $count = 0; + //an animated gif contains multiple "frames", with each frame having a + //header made up of: + // * a static 4-byte sequence (\x00\x21\xF9\x04) + // * 4 variable bytes + // * a static 2-byte sequence (\x00\x2C) + + // We read through the file til we reach the end of the file, or we've found + // at least 2 frame headers + while(!feof($fh) && $count < 2) { + $chunk = fread($fh, 1024 * 100); //read 100kb at a time + $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00\x2C#s', $chunk, $matches); + } + fclose($fh); + return $count > 1; + + /* $output = array(); $retval = 0; @@ -549,6 +570,8 @@ function isAnimGif($sFile) { } return true; + * + */ } /** diff --git a/conlite/includes/functions.general.php b/conlite/includes/functions.general.php index ff3ccce..8fc9813 100644 --- a/conlite/includes/functions.general.php +++ b/conlite/includes/functions.general.php @@ -1428,23 +1428,9 @@ function isImageMagickAvailable() { return false; } } - - $output = array(); - $retval = 0; - - @exec("convert", $output, $retval); - - if (!is_array($output) || count($output) == 0) { - return false; - } - - if (strpos($output[0], "ImageMagick") !== false) { - $_imagemagickAvailable = true; - return true; - } else { - $_imagemagickAvailable = false; - return false; - } + + $_imagemagickAvailable = (extension_loaded('imagick'))?true:false; + return $_imagemagickAvailable; } /**