Fix pb with imagick

This commit is contained in:
Laurent Destailleur 2017-08-29 13:41:44 +02:00
parent 22ca29a51f
commit eebaff95cf
2 changed files with 24 additions and 14 deletions

View File

@ -1565,12 +1565,14 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile=
* @param string $fileinput Input file name * @param string $fileinput Input file name
* @param string $ext Format of target file (It is also extension added to file if fileoutput is not provided). * @param string $ext Format of target file (It is also extension added to file if fileoutput is not provided).
* @param string $fileoutput Output filename * @param string $fileoutput Output filename
* @return int <0 if KO, >0 if OK * @return int <0 if KO, 0=Nothing done, >0 if OK
*/ */
function dol_convert_file($fileinput,$ext='png',$fileoutput='') function dol_convert_file($fileinput,$ext='png',$fileoutput='')
{ {
global $langs; global $langs;
if (class_exists('Imagick'))
{
$image=new Imagick(); $image=new Imagick();
$ret = $image->readImage($fileinput); $ret = $image->readImage($fileinput);
if ($ret) if ($ret)
@ -1594,6 +1596,11 @@ function dol_convert_file($fileinput,$ext='png',$fileoutput='')
{ {
return -1; return -1;
} }
}
else
{
return 0;
}
} }

View File

@ -1235,10 +1235,13 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ( (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) if ( (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($file)))
&& (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file))) && (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file)))
) )
{
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
{ {
$ret = dol_convert_file($file, 'png', $fileimage); $ret = dol_convert_file($file, 'png', $fileimage);
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }
}
$heightforphotref=70; $heightforphotref=70;
if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60;