From 553bb728c63cb7a547a7aa2f9f224ec4fc566d0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Dec 2019 22:13:50 +0100 Subject: [PATCH 1/2] Fix break not necessary --- htdocs/core/lib/images.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index fa68301a298..341f79d8189 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -372,7 +372,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) $image = imagegif($img, $fileDest); break; case IMAGETYPE_JPEG: // 2 - return imagejpeg($img, $fileDest, $quality); + $image = imagejpeg($img, $fileDest, $quality); break; case IMAGETYPE_PNG: // 3 $image = imagepng($img, $fileDest, $quality); From a7571054f06b4ca289b500a2c5a149044760ed38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Dec 2019 22:19:35 +0100 Subject: [PATCH 2/2] Fix if exif not available --- htdocs/core/lib/images.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 341f79d8189..c40e0c1e406 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -322,7 +322,7 @@ function dolRotateImage($file_path) */ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) { - if (function_exists('exif_read_data') ) { + if (function_exists('exif_read_data')) { $exif = exif_read_data($fileSource); if ($exif && isset($exif['Orientation'])) { @@ -455,13 +455,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $imgWidth = $infoImg[0]; // Largeur de l'image $imgHeight = $infoImg[1]; // Hauteur de l'image - $exif = exif_read_data($filetoread); - $ort= false; - if ($exif && !empty($exif['Orientation'])) { - $ort = $exif['Orientation']; + $ort = false; + if (function_exists('exif_read_data')) { + $exif = exif_read_data($filetoread); + if ($exif && !empty($exif['Orientation'])) { + $ort = $exif['Orientation']; + } } - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged @@ -535,6 +536,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; } + $exifAngle = false; if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { switch($ort) @@ -557,7 +559,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - if($exifAngle) + if ($exifAngle) { $rotated = false; @@ -581,8 +583,6 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } } - - // Initialisation des dimensions de la vignette si elles sont superieures a l'original if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; }