Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from odie2/master
Browse files Browse the repository at this point in the history
* odie2-master:
  Missed $size...
  Fixed upscale if both width and height are lesser than destination.
  • Loading branch information
mcaskill committed Dec 6, 2016
2 parents ea90863 + cfbe976 commit 8128bc6
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/ManualImageCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,12 @@ public function cropImage( $data = null, $silent_result = false ) {
$is_wider = ( $dst_w > $size["width"] );

if ( $is_higher || $is_wider ) {
if ( $is_higher ) {
$scale = $src_h / $size["height"];
} else {
$scale = $src_w / $size["width"];
}
$size_ratio = max($dst_w / $size["width"], $dst_h / $size["height"]);

$src_w = $src_w / $scale;
$src_h = $src_h / $scale;
$src_x = $src_x / $scale;
$src_y = $src_y / $scale;
$src_w = round($dst_w / $size_ratio);
$src_h = round($dst_h / $size_ratio);
$src_x = round($src_x / $size_ratio);
$src_y = round($src_y / $size_ratio);
}

//saves the selected area
Expand Down

0 comments on commit 8128bc6

Please sign in to comment.