Skip to content
Open
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
16 changes: 11 additions & 5 deletions app/Controller/Component/QimageComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,21 @@ public function resize($data){
// If width or height not defined, it's necessary calculate proportional size
if (!($width > 0 && $height > 0)){


$source_side;
$source_origin;

// Verify if image is horizontal or vertical
if ($original_height > $original_width){
$height = ($data['width'] > 0) ? $data['width'] : $data['height'];
$width = ($height / $original_height) * $original_width;
$source_side = ($data['width'] > 0) ? $data['width'] : $data['height'];
$source_origin = ($data['width'] > 0) ? $original_width : $original_height;
} else {
$width = ($data['height'] > 0) ? $data['height'] : $data['width'];
$height = ($width / $original_width) * $original_height;
$source_side = ($data['height'] > 0) ? $data['height'] : $data['width'];
$source_origin = ($data['height'] > 0) ? $original_height : $original_width;
}

$factor = ($source_side / $source_origin);
$height = $factor * $original_height;
$width = $factor * $original_width;

}

Expand Down