Skip to content

Commit

Permalink
Fix upscaling bug with canvas size
Browse files Browse the repository at this point in the history
  • Loading branch information
technicalguru committed Sep 22, 2021
1 parent 6ceef84 commit cf9d69b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TgUtils/ImageUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public static function cropAndScale($imagePath, $variation, $newHeight, $newWidt
$height = $image->getImageHeight();
$actions = self::computeCropAndScale($width, $height, $newWidth, $newHeight, $options);
if ($actions->scale != 1) {
$image->scaleImage($actions->factor * $width, $actions->factor * $height);
$image->scaleImage($actions->factor * $width, $actions->factor * $height, FALSE);
$image->setImagePage(0,0,0,0); // This does some trick caused by scaling (canvas issue)
}
if ($image->cropImage($actions->width, $actions->height, $actions->x, $actions->y)) {
// Writing it
Expand Down Expand Up @@ -261,7 +262,6 @@ public static function computeCropAndScale($origWidth, $origHeight, $maxWidth, $
$rc->options = $options;

if ($rc->height < $maxHeight) {
\TgLog\Log::error('path1');
// scale up and crop along X axis
$rc->factor = $maxHeight / $origHeight;
$rc->width = $rc->factor * $origWidth;
Expand Down

0 comments on commit cf9d69b

Please sign in to comment.