Skip to content

Commit

Permalink
Merge pull request #427 from sgulseth/ceil-resize-transformation
Browse files Browse the repository at this point in the history
When resizing with one param round up the other calculated value
  • Loading branch information
rexxars committed Feb 1, 2016
2 parents 3384ddc + f3e812a commit f5cfcf7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions library/Imbo/Image/Transformation/Resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function transform(EventInterface $event) {

// Calculate width or height if not both have been specified
if (!$height) {
$height = ($originalHeight / $originalWidth) * $width;
$height = ceil(($originalHeight / $originalWidth) * $width);
} else if (!$width) {
$width = ($originalWidth / $originalHeight) * $height;
$width = ceil(($originalWidth / $originalHeight) * $height);
}

try {
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/features/image-transformations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Feature: Imbo enables dynamic transformations of images
| modulate:b=1,s=2 | 599 | 417 |
| modulate:b=1,s=2,h=3 | 599 | 417 |
| progressive | 599 | 417 |
| resize:width=100 | 100 | 69 |
| resize:height=200 | 287 | 200 |
| resize:width=100 | 100 | 70 |
| resize:height=200 | 288 | 200 |
| resize:width=100,height=100 | 100 | 100 |
| rotate:angle=90 | 417 | 599 |
| sepia | 599 | 417 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function getResizeParams() {
'params' => ['width' => 100],
'transformation' => true,
'resizedWidth' => 100,
'resizedHeight' => 69,
'resizedHeight' => 70,
],
'only height' => [
'params' => ['height' => 100],
'transformation' => true,
'resizedWidth' => 143,
'resizedWidth' => 144,
'resizedHeight' => 100,
],
'width and height' => [
Expand Down

0 comments on commit f5cfcf7

Please sign in to comment.