root4root / imgresize
Yet another images resize library
v1.0.1
2020-09-23 21:29 UTC
Requires
- php: >=5.4.0
- ext-gd: *
Suggests
- ext-exif: Rotate jpg files
This package is not auto-updated.
Last update: 2024-09-19 16:47:11 UTC
README
Yet another library based on gd to resize images with method chaining.
Examle
require_once ('vendor/autoload.php'); use Root4root\ImgResize\ImgResize; $image = new ImgResize('pathToImage.jpg'); $image->resampleToHeight(500) ->sharpen() ->save('pathToSave.gif'); $watermark = new ImgResize('pathToWatermark.png'); $image->addImage(new ImgResize('anotherImage.png')) ->joinVertical() ->watermark($watermark) ->save('pathToSave.jpg'); $image->watermark($watermark)->save('pathToSave2.jpg');
Notes
Every time you modify image, ImgResize returns new instanse of self as a result. So you could assign instance to a variable at any moment, which will stay immutable. Be careful with saving instances due to the memory limit, though.
$imageWithWatermark = (new ImgResize('pathToImage.jpg'))->watermark(new ImgResize('pathToWater.png')); $imageWithWatermark->resampleToRectangle(500,500)->save('path.jpg'); //Fits image to rectangle by height or width - which is bigger. $imageWithWatermark->resampleToWidth(1000)->sharpen()->save('path.png'); //Still one resample - best quality