diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index b8c0472b7518d3a73ab6491f6e507a6a5a3b96aa..e25709fd303f6f5a677e03559619bb2980bacdeb 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -375,7 +375,7 @@ class FileUpload } /** - * Enter description here ... + * trimFileName * * @param string $name Filename * @param string $type ??? @@ -404,43 +404,7 @@ class FileUpload } /** - * Enter description here ... - * - * @param unknown_type $file_path ??? - * @return boolean Success or not - */ - protected function orientImage($file_path) - { - $exif = @exif_read_data($file_path); - if ($exif === false) { - return false; - } - $orientation = intval(@$exif['Orientation']); - if (!in_array($orientation, array(3, 6, 8))) { - return false; - } - $image = @imagecreatefromjpeg($file_path); - switch ($orientation) { - case 3: - $image = @imagerotate($image, 180, 0); - break; - case 6: - $image = @imagerotate($image, 270, 0); - break; - case 8: - $image = @imagerotate($image, 90, 0); - break; - default: - return false; - } - $success = imagejpeg($image, $file_path); - // Free up memory (imagedestroy does not delete files): - @imagedestroy($image); - return $success; - } - - /** - * Enter description here ... + * handleFileUpload * * @param string $uploaded_file Uploade file * @param string $name Name diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 669da7b751bec355c55b7f38a99f296c3fcefc9c..9cf745a0da070cd8be983effb46240bdf1ee39f2 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -291,6 +291,46 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s } +/** + * dolRotateImage if image is a jpg file. + * Currently use an autodetection to know if we can rotate. + * TODO Introduce a new parameter to force rotate. + * + * @param string $file_path Full path to image to rotate + * @return boolean Success or not + */ +function dolRotateImage($file_path) +{ + $exif = @exif_read_data($file_path); + if ($exif === false) { + return false; + } + $orientation = intval(@$exif['Orientation']); + if (!in_array($orientation, array(3, 6, 8))) { + return false; + } + $image = @imagecreatefromjpeg($file_path); + switch ($orientation) { + case 3: + $image = @imagerotate($image, 180, 0); + break; + case 6: + $image = @imagerotate($image, 270, 0); + break; + case 8: + $image = @imagerotate($image, 90, 0); + break; + default: + return false; + } + $success = imagejpeg($image, $file_path); + // Free up memory (imagedestroy does not delete files): + @imagedestroy($image); + return $success; +} + + + /** * Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp). * If file is myfile.jpg, new file may be myfile_small.jpg