Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions server/php/UploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,22 @@ public function __construct($options = null, $initialize = true, $error_messages
// Command or path for to the ImageMagick identify binary:
'identify_bin' => 'identify',
'image_versions' => array(
// The empty image version key defines options for the original image:
// Keep in mind that these options are inherited by all other image versions!
// The empty image version key defines options for the original image.
// Keep in mind: these image manipulations are inherited by all other image versions from this point onwards.
// Also note that the property 'no_cache' is not inherited, since it's not a manipulation.
'' => array(
// Automatically rotate images based on EXIF meta data:
'auto_orient' => true
),
// Uncomment the following to create medium sized images:
// You can add arrays to generate different versions.
// The name of the key is the name of the version (example: 'medium').
// the array contains the options to apply.
/*
'medium' => array(
'max_width' => 800,
'max_height' => 600
),
*/
*/
'thumbnail' => array(
// Uncomment the following to use a defined directory for the thumbnails
// instead of a subdirectory based on the version identifier.
Expand All @@ -154,9 +157,13 @@ public function __construct($options = null, $initialize = true, $error_messages
//'upload_url' => $this->get_full_url().'/thumb/',
// Uncomment the following to force the max
// dimensions and e.g. create square thumbnails:
//'crop' => true,
'max_width' => 80,
'max_height' => 80
// 'auto_orient' => true,
// 'crop' => true,
// 'jpeg_quality' => 70,
// 'no_cache' => true, (there's a caching option, but this remembers thumbnail sizes from a previous action!)
// 'strip' => true, (this strips EXIF tags, such as geolocation)
'max_width' => 80, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height.
'max_height' => 80 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width.
)
),
'print_response' => true
Expand Down Expand Up @@ -863,26 +870,32 @@ protected function imagick_create_scaled_image($file_name, $version, $options) {
$image_oriented = false;
if (!empty($options['auto_orient'])) {
$image_oriented = $this->imagick_orient_image($image);
}
}

$image_resize = false;
$new_width = $max_width = $img_width = $image->getImageWidth();
$new_height = $max_height = $img_height = $image->getImageHeight();
if (!empty($options['max_width'])) {
$new_width = $max_width = $options['max_width'];
}
if (!empty($options['max_height'])) {
$new_height = $max_height = $img_height = $image->getImageHeight();

// use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty()
if (isset($options['max_width'])) {
$image_resize = true;
$new_width = $max_width = $options['max_width'];
}
if (isset($options['max_height'])) {
$image_resize = true;
$new_height = $max_height = $options['max_height'];
}
$image_strip = false;
if( !empty($options["strip"]) ) {
$image_strip = $options["strip"];
}

$image_strip = (isset($options['strip']) ? $options['strip'] : false);

if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) {
if ($file_path !== $new_file_path) {
return copy($file_path, $new_file_path);
}
return true;
}
$crop = !empty($options['crop']);
$crop = (isset($options['crop']) ? $options['crop'] : false);

if ($crop) {
$x = 0;
$y = 0;
Expand Down