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