-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #769 #770
Fix #769 #770
Changes from all commits
40f282d
f205675
06d0c09
892a263
c1a4d15
451ec93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,16 @@ public function load(ImageInterface $image, array $options = array()) | |
$widthRatio = $width / $origWidth; | ||
$heightRatio = $height / $origHeight; | ||
|
||
$ratio = min($widthRatio, $heightRatio); | ||
// faster check than is_null | ||
if (null === $width || null === $height) { | ||
$ratio = max($widthRatio, $heightRatio); | ||
} else { | ||
$ratio = min($widthRatio, $heightRatio); | ||
} | ||
|
||
if ($ratio > 1) { | ||
return $image; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be controversial thing, discuss on this 🎱 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hah, now that's my kinda fix! 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be an option, defaulting to off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking more like, creating another filter "scale" which will do either, the filters should do only what they should, I don't know maybe it's just clear that way, moreover downscale and upscale should be derived from scale There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine for me too |
||
|
||
$filter = new Resize(new Box($origWidth * $ratio, $origHeight * $ratio)); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be
$ratio = ($width === null || $height === null) ? max($widthRatio, $heightRatio) : min($widthRatio, $heightRatio);
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, either way that is just a style thing, I don't think it will be a performance issue, so I'm okay with anything. you might see this info http://stackoverflow.com/a/11643364
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Symfony we generally use
null === $foo