Skip to content

Commit 454265f

Browse files
author
jbostoen
authored
Update UploadHandler.php
imagick_create_scaled_image: - jpeg_quality was ignored if it was the only parameter set (similar to previous patch for 'strip' exif information) - instead of a negative condition, turned it around: if dimensions are within limits and no changes required (strip exif, jpeg quality, orientation), then return original image - added comment warning about the implications of setting options on the 'original' image ( version '' ). All other versions inherit those settings.
1 parent a7ddbeb commit 454265f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/php/UploadHandler.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function __construct($options = null, $initialize = true, $error_messages
132132
'identify_bin' => 'identify',
133133
'image_versions' => array(
134134
// The empty image version key defines options for the original image:
135+
// Keep in mind that these options are inherited by all other image versions!
135136
'' => array(
136137
// Automatically rotate images based on EXIF meta data:
137138
'auto_orient' => true
@@ -871,7 +872,13 @@ protected function imagick_create_scaled_image($file_name, $version, $options) {
871872
if (!empty($options['max_height'])) {
872873
$new_height = $max_height = $options['max_height'];
873874
}
874-
if (!($image_oriented || $max_width < $img_width || $max_height < $img_height || !empty($options['strip']) )) {
875+
876+
$image_strip = false;
877+
if( !empty($options["strip"]) ) {
878+
$image_strip = $options["strip"];
879+
}
880+
881+
if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !image_strip && empty($options["jpeg_quality"]) ) {
875882
if ($file_path !== $new_file_path) {
876883
return copy($file_path, $new_file_path);
877884
}
@@ -917,7 +924,7 @@ protected function imagick_create_scaled_image($file_name, $version, $options) {
917924
}
918925
break;
919926
}
920-
if (!empty($options['strip'])) {
927+
if ( $image_strip ) {
921928
$image->stripImage();
922929
}
923930
return $success && $image->writeImage($new_file_path);

0 commit comments

Comments
 (0)