1

I have the code:

use yii\imagine\Image;
use Imagine\Image\Box;
...
$path = Yii::getAlias('@app'). '/temp';
Image::frame($path  . '/1.jpg')->thumbnail(new Box(200, 200))->save($path  . '/2.jpg', ['quality' => 100]);

Original image: 1.jpg

and result: 2.jpg

The result have the white border. How is disable border?

If there is no way to disable border, how do change without circumcision and keeping the aspect ratio?

Thanks you!

Michael S
  • 11
  • 1
  • 3
  • 1
    just a suggestion.. inspect your code for check the element involved in box border and the set a proper css style for change it dierctly in you page or element. – ScaisEdge Oct 09 '15 at 10:51

1 Answers1

0

I just had this problem and fixed it by taking a look at the docs:

http://www.yiiframework.com/doc-2.0/yii-imagine-baseimage.html#frame()-detail

public static \Imagine\Image\ImageInterface frame ( $filename, $margin = 20, $color = '666', $alpha = 100 )

Basically, the frame method is built to do exactly what you don't want it to do. To fix it, use the margin parameter as such:

Image::frame($path  . '/1.jpg', 0)->thumbnail(new Box(200, 200))->save($path  . '/2.jpg', ['quality' => 100]);
Fittersman
  • 625
  • 2
  • 11
  • 22