-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from scuben/fix-upscale-size
fix upscale size not being calculated correctly
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
Tests/Imagine/Filter/Loader/FloatToIntCastByRoundUpscaleFilterLoaderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Liip\ImagineBundle\Tests\Filter; | ||
|
||
use Imagine\Gd\Image; | ||
use Imagine\Gd\Imagine; | ||
use Liip\ImagineBundle\Imagine\Filter\Loader\UpscaleFilterLoader; | ||
use Liip\ImagineBundle\Tests\AbstractTest; | ||
|
||
/** | ||
* @covers Liip\ImagineBundle\Imagine\Filter\Loader\UpscaleFilterLoader | ||
* | ||
* Due to int casting in Imagine\Image\Box which can lead to wrong pixel | ||
* numbers ( e.g. float(201) casted to int(200) ). Solved by round the | ||
* floating number before passing to the Box constructor. | ||
*/ | ||
class FloatToIntCastByRoundUpscaleFilterLoaderTest extends AbstractTest | ||
{ | ||
public function testLoad() | ||
{ | ||
$loader = new UpscaleFilterLoader(); | ||
$imagine = new Imagine(); | ||
$image = $imagine->open(__DIR__.'/../../../Fixtures/assets/square-50x50.png'); | ||
|
||
$options = array( | ||
'min' => array(201, 201), | ||
); | ||
|
||
$image = $loader->load($image, $options); | ||
$size = $image->getSize(); | ||
|
||
$this->assertEquals($options['min'], array($size->getWidth(), $size->getHeight())); | ||
} | ||
} |