Skip to content

Commit

Permalink
Round resize configuration after scaling, closes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Jan 23, 2017
1 parent 291363a commit 4068dda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/PictureGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function ($density) use ($width1x) {
private function generateSrcsetItem(ImageInterface $image, PictureConfigurationItemInterface $config, $density, $descriptorType, $width1x)
{
$resizeConfig = clone $config->getResizeConfig();
$resizeConfig->setWidth($resizeConfig->getWidth() * $density);
$resizeConfig->setHeight($resizeConfig->getHeight() * $density);
$resizeConfig->setWidth(round($resizeConfig->getWidth() * $density));
$resizeConfig->setHeight(round($resizeConfig->getHeight() * $density));

$resizedImage = $this->resizer->resize($image, $resizeConfig, $this->resizeOptions);

Expand Down
2 changes: 1 addition & 1 deletion tests/PictureGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function (

$pictureConfig = (new PictureConfiguration())
->setSize((new PictureConfigurationItem())
->setDensities('1x, 1.35354x, 2x')
->setDensities('1x, 1.35354x, 1.9999x')
->setResizeConfig((new ResizeConfiguration())
->setWidth(99)
->setHeight(99)
Expand Down

0 comments on commit 4068dda

Please sign in to comment.