Skip to content

Commit

Permalink
Fix typo in ImageHelper::targetDimensions()
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjhanson committed Oct 18, 2022
1 parent 70abd00 commit ca4b811
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/helpers/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Craft;
use craft\errors\ImageException;
use craft\image\Svg;
use Imagick;
use Throwable;
use TypeError;
use yii\base\InvalidArgumentException;

/**
Expand Down Expand Up @@ -102,8 +105,8 @@ public static function targetDimensions(
$imageRatio = $sourceWidth / $sourceHeight;

if ($mode === 'fit' || $imageRatio === $transformRatio) {
$targetWidth = min($sourceWidth, $transformWidth, (int)round($sourceWidth / $factor));
$targetHeight = min($sourceHeight, $transformHeight, (int)round($sourceHeight / $factor));
$targetWidth = min($sourceWidth, $width, (int)round($sourceWidth / $factor));
$targetHeight = min($sourceHeight, $height, (int)round($sourceHeight / $factor));
return [$targetWidth, $targetHeight];
}

Expand Down Expand Up @@ -252,7 +255,7 @@ public static function imageSize(string $filePath): array

$image = Craft::$app->getImages()->loadImage($filePath);
return [$image->getWidth(), $image->getHeight()];
} catch (\Throwable $exception) {
} catch (Throwable $exception) {
return [0, 0];
}
}
Expand All @@ -262,12 +265,12 @@ public static function imageSize(string $filePath): array
*
* @param resource $stream
* @return array|false
* @throws \TypeError
* @throws TypeError
*/
public static function imageSizeByStream($stream)
{
if (!is_resource($stream)) {
throw new \TypeError('Argument passed should be a resource.');
throw new TypeError('Argument passed should be a resource.');
}

$dimensions = [];
Expand Down Expand Up @@ -395,9 +398,9 @@ public static function parseSvgSize(string $svg): array
* Clean EXIF data from an image loaded inside an Imagick instance, taking
* care not to wipe the ICC profile.
*
* @param \Imagick $imagick
* @param Imagick $imagick
*/
public static function cleanExifDataFromImagickImage(\Imagick $imagick)
public static function cleanExifDataFromImagickImage(Imagick $imagick)
{
$config = Craft::$app->getConfig()->getGeneral();

Expand Down

0 comments on commit ca4b811

Please sign in to comment.