claviska / SimpleImage

A PHP class that makes working with images and GD as simple as possible.
MIT License
1.38k stars 382 forks source link

A feature to fit image in a fixed canvas size with blur background of original image. #294

Closed aatishdumps closed 2 years ago

aatishdumps commented 2 years ago

Can you please add a feature to fit image in a fixed canvas size with blur background of original image ? something like this image (https://i.stack.imgur.com/b4pDj.jpg)

claviska commented 2 years ago

You can do this with:

$bottom = new \claviska\SimpleImage();
$top = new \claviska\SimpleImage();

$top
  ->fromFile('parrot.jpg')
  ->bestFit(400, 600)
  ->border('white', 8);

$bottom
  ->fromFile('parrot.jpg')
  ->autoOrient()
  ->blur('gaussian', 40)
  ->overlay($top)
  ->toScreen();

Result:

example

aatishdumps commented 2 years ago

sorry i want to fit the image in square image like instagram. here are few ref. images : vertical horizntl I hope u understood the requirement of output