Skip to content

Commit

Permalink
Merge branch 'release/1.0.7' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Apr 24, 2021
2 parents 68954fa + e7cac99 commit 645bcb9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ImageOptimize Sharp Image Transform Changelog

## 1.0.7 - 2021.04.23
### Added
* Added a setting to control the amount an image needs to be scaled down for automatic sharpening to be applied (https://github.com/nystudio107/craft-imageoptimize/issues/263)

## 1.0.6 - 2021.02.03
### Fixed
* Map the `fit` Craft transform method to `inside` to avoid letterboxing
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-imageoptimize-sharp",
"description": "Provides an Sharp image transform type for the ImageOptimize plugin.",
"type": "image-transform",
"version": "1.0.6",
"version": "1.0.7",
"keywords": [
"craftcms",
"sharp",
Expand All @@ -24,7 +24,7 @@
"prefer-stable": true,
"require": {
"craftcms/cms": "^3.0.0",
"nystudio107/craft-imageoptimize": "^1.6.0"
"nystudio107/craft-imageoptimize": "^1.6.33"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions src/imagetransforms/SharpImageTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ public function getTransformUrl(Asset $asset, $transform)
// Handle auto-sharpening
if ($settings->autoSharpenScaledImages) {
// See if the image has been scaled >= 50%
$widthScale = $asset->getWidth() / ($transform->width ?? $asset->getWidth());
$heightScale = $asset->getHeight() / ($transform->height ?? $asset->getHeight());
if (($widthScale >= 2.0) || ($heightScale >= 2.0)) {
$widthScale = (int)((($transform->width ?? $asset->getWidth()) / $asset->getWidth()) * 100);
$heightScale = (int)((($transform->height ?? $asset->getHeight()) / $asset->getHeight()) * 100);
if (($widthScale >= (int)$settings->sharpenScaledImagePercentage) || ($heightScale >= (int)$settings->sharpenScaledImagePercentage)) {
$edits['sharpen'] = true;
}
}
Expand Down

0 comments on commit 645bcb9

Please sign in to comment.