yii2 resize images maintaining aspect ratio with Imagine

ps202 picture ps202 · May 17, 2015 · Viewed 8.6k times · Source

I got this code in yii2:

Image::thumbnail($path, 100, 100)->save($thumbnail, ['quality' => 50]);

I thought that it will resize the original image maintaining the aspect ratio. But it just creates a box... What can be wrong?

Answer

vitalik_74 picture vitalik_74 · May 18, 2015

You may use like that:

use Imagine\Image\Box;

Image::frame($path)
->thumbnail(new Box(100, 100))
->save($thumbnail, ['quality' => 50]);