fixes for exec and imagemagick

Dieser Commit ist enthalten in:
o.pinke 2022-11-11 19:46:41 +01:00
Ursprung 6a150745dd
Commit b6ca65ede8
2 geänderte Dateien mit 32 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -516,12 +516,14 @@ function capiImgScaleImageMagick($img, $maxX, $maxY, $crop = false, $expand = fa
} }
/* Try to execute convert */ /* Try to execute convert */
$output = array(); if (function_exists("exec")) {
$retVal = 0; $output = array();
if ($crop) { $retVal = 0;
exec("convert -gravity center -quality " . $quality . " -crop {$maxX}x{$maxY}+1+1 \"$filename\" $cacheFile", $output, $retVal); if ($crop) {
} else { exec("convert -gravity center -quality " . $quality . " -crop {$maxX}x{$maxY}+1+1 \"$filename\" $cacheFile", $output, $retVal);
exec("convert -quality " . $quality . " -geometry {$targetX}x{$targetY} \"$filename\" $cacheFile", $output, $retVal); } else {
exec("convert -quality " . $quality . " -geometry {$targetX}x{$targetY} \"$filename\" $cacheFile", $output, $retVal);
}
} }
if (!file_exists($cacheFile)) { 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) * @return boolean true (gif is animated)/ false (single frame gif)
*/ */
function isAnimGif($sFile) { 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(); $output = array();
$retval = 0; $retval = 0;
@ -549,6 +570,8 @@ function isAnimGif($sFile) {
} }
return true; return true;
*
*/
} }
/** /**

Datei anzeigen

@ -1428,23 +1428,9 @@ function isImageMagickAvailable() {
return false; return false;
} }
} }
$output = array(); $_imagemagickAvailable = (extension_loaded('imagick'))?true:false;
$retval = 0; return $_imagemagickAvailable;
@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;
}
} }
/** /**