@@ -131,19 +131,22 @@ public function __construct($options = null, $initialize = true, $error_messages
131
131
// Command or path for to the ImageMagick identify binary:
132
132
'identify_bin ' => 'identify ' ,
133
133
'image_versions ' => array (
134
- // 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!
134
+ // The empty image version key defines options for the original image.
135
+ // Keep in mind: these image manipulations are inherited by all other image versions from this point onwards.
136
+ // Also note that the property 'no_cache' is not inherited, since it's not a manipulation.
136
137
'' => array (
137
138
// Automatically rotate images based on EXIF meta data:
138
139
'auto_orient ' => true
139
140
),
140
- // Uncomment the following to create medium sized images:
141
+ // You can add arrays to generate different versions.
142
+ // The name of the key is the name of the version (example: 'medium').
143
+ // the array contains the options to apply.
141
144
/*
142
145
'medium' => array(
143
146
'max_width' => 800,
144
147
'max_height' => 600
145
148
),
146
- */
149
+ */
147
150
'thumbnail ' => array (
148
151
// Uncomment the following to use a defined directory for the thumbnails
149
152
// instead of a subdirectory based on the version identifier.
@@ -154,9 +157,13 @@ public function __construct($options = null, $initialize = true, $error_messages
154
157
//'upload_url' => $this->get_full_url().'/thumb/',
155
158
// Uncomment the following to force the max
156
159
// dimensions and e.g. create square thumbnails:
157
- //'crop' => true,
158
- 'max_width ' => 80 ,
159
- 'max_height ' => 80
160
+ // 'auto_orient' => true,
161
+ // 'crop' => true,
162
+ // 'jpeg_quality' => 70,
163
+ // 'no_cache' => true, (there's a caching option, but this remembers thumbnail sizes from a previous action!)
164
+ // 'strip' => true, (this strips EXIF tags, such as geolocation)
165
+ 'max_width ' => 80 , // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height.
166
+ 'max_height ' => 80 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width.
160
167
)
161
168
),
162
169
'print_response ' => true
@@ -863,26 +870,32 @@ protected function imagick_create_scaled_image($file_name, $version, $options) {
863
870
$ image_oriented = false ;
864
871
if (!empty ($ options ['auto_orient ' ])) {
865
872
$ image_oriented = $ this ->imagick_orient_image ($ image );
866
- }
873
+ }
874
+
875
+ $ image_resize = false ;
867
876
$ new_width = $ max_width = $ img_width = $ image ->getImageWidth ();
868
- $ new_height = $ max_height = $ img_height = $ image ->getImageHeight ();
869
- if (!empty ($ options ['max_width ' ])) {
870
- $ new_width = $ max_width = $ options ['max_width ' ];
871
- }
872
- if (!empty ($ options ['max_height ' ])) {
877
+ $ new_height = $ max_height = $ img_height = $ image ->getImageHeight ();
878
+
879
+ // use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
880
+ if (isset ($ options ['max_width ' ])) {
881
+ $ image_resize = true ;
882
+ $ new_width = $ max_width = $ options ['max_width ' ];
883
+ }
884
+ if (isset ($ options ['max_height ' ])) {
885
+ $ image_resize = true ;
873
886
$ new_height = $ max_height = $ options ['max_height ' ];
874
887
}
875
- $ image_strip = false ;
876
- if ( !empty ($ options ["strip " ]) ) {
877
- $ image_strip = $ options ["strip " ];
878
- }
888
+
889
+ $ image_strip = (isset ($ options ['strip ' ]) ? $ options ['strip ' ] : false );
890
+
879
891
if ( !$ image_oriented && ($ max_width >= $ img_width ) && ($ max_height >= $ img_height ) && !$ image_strip && empty ($ options ["jpeg_quality " ]) ) {
880
892
if ($ file_path !== $ new_file_path ) {
881
893
return copy ($ file_path , $ new_file_path );
882
894
}
883
895
return true ;
884
896
}
885
- $ crop = !empty ($ options ['crop ' ]);
897
+ $ crop = (isset ($ options ['crop ' ]) ? $ options ['crop ' ] : false );
898
+
886
899
if ($ crop ) {
887
900
$ x = 0 ;
888
901
$ y = 0 ;
0 commit comments