diff --git a/admin/include/functions.php b/admin/include/functions.php index 0881856e8..129af0dc9 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -3692,7 +3692,7 @@ function get_graphics_library() switch (pwg_image::get_library()) { case 'ext_imagick': - exec($conf['ext_imagick_dir'].'convert -version', $returnarray); + exec($conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command().' -version', $returnarray); if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match)) { $library.= '/'.$match[1]; diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index b5eb59b35..bbb686624 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -552,7 +552,7 @@ function upload_file_pdf($representative_ext, $file_path) $representative_file_path = original_to_representative($file_path, $ext); prepare_directory(dirname($representative_file_path)); - $exec = $conf['ext_imagick_dir'].'convert'; + $exec = $conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command(); if ('jpg' == $ext) { $exec.= ' -quality '.$jpg_quality; @@ -601,7 +601,7 @@ function upload_file_heic($representative_ext, $file_path) list($w,$h) = get_optimal_dimensions_for_representative(); - $exec = $conf['ext_imagick_dir'].'convert'; + $exec = $conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command(); $exec.= ' -sampling-factor 4:2:0 -quality 85 -interlace JPEG -colorspace sRGB -auto-orient +repage -resize "'.$w.'x'.$h.'>"'; $exec.= ' "'.realpath($file_path).'"'; $exec.= ' "'.$representative_file_path.'"'; @@ -651,7 +651,7 @@ function upload_file_tiff($representative_ext, $file_path) prepare_directory(dirname($representative_file_path)); - $exec = $conf['ext_imagick_dir'].'convert'; + $exec = $conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command(); if ('jpg' == $conf['tiff_representative_ext']) { @@ -798,7 +798,7 @@ function upload_file_psd($representative_ext, $file_path) prepare_directory(dirname($representative_file_path)); - $exec = $conf['ext_imagick_dir'].'convert'; + $exec = $conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command(); $exec .= ' "'.realpath($file_path).'"'; @@ -860,7 +860,7 @@ function upload_file_eps($representative_ext, $file_path) // convert -density 300 image.eps -resize 2048x2048 image.png - $exec = $conf['ext_imagick_dir'].'convert'; + $exec = $conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command(); $exec.= ' -density 300'; $exec.= ' "'.realpath($file_path).'"'; $exec.= ' -resize 2048x2048'; diff --git a/admin/include/image.class.php b/admin/include/image.class.php index 0b17ef5f1..ace71bc3b 100644 --- a/admin/include/image.class.php +++ b/admin/include/image.class.php @@ -368,6 +368,29 @@ class pwg_image return (extension_loaded('imagick') and class_exists('Imagick')); } + static function get_ext_imagick_command() + { + global $page, $conf; + + if (!isset($page['ext_imagick_command'])) + { + $retval=null; + $cmd_out=null; + // check if magick is in path + exec('command -v '.$conf['ext_imagick_dir'].'magick', $cmd_out , $retval ); + if (0 == $retval) + { + $page['ext_imagick_command'] = $cmd_out[0]; + } + else + { + $page['ext_imagick_command'] = $conf['ext_imagick_dir'].'convert'; + } + } + + return $page['ext_imagick_command']; + } + static function is_ext_imagick() { global $conf; @@ -376,7 +399,8 @@ class pwg_image { return false; } - @exec($conf['ext_imagick_dir'].'convert -version', $returnarray); + + @exec($conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command().' -version', $returnarray); if (is_array($returnarray) and !empty($returnarray[0]) and preg_match('/ImageMagick/i', $returnarray[0])) { if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match)) @@ -704,7 +728,7 @@ class image_ext_imagick implements imageInterface $this->add_command('sampling-factor', '4:2:2' ); } - $exec = $this->imagickdir.'convert'; + $exec = $this->imagickdir.pwg_image::get_ext_imagick_command(); $exec .= ' "'.realpath($this->source_filepath).'"'; foreach ($this->commands as $command => $params) diff --git a/admin/maintenance_actions.php b/admin/maintenance_actions.php index a15dba72f..ce4c6b842 100644 --- a/admin/maintenance_actions.php +++ b/admin/maintenance_actions.php @@ -320,7 +320,7 @@ switch (pwg_image::get_library()) { case 'ext_imagick': $library = 'External ImageMagick'; - exec($conf['ext_imagick_dir'].'convert -version', $returnarray); + exec($conf['ext_imagick_dir'].pwg_image::get_ext_imagick_command().' -version', $returnarray); if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match)) { $library .= ' ' . $match[1];