PHP Thumbnail is a PHP image manipulation library providing an easier and expressive way to create thumbnails to improve SEO of your website.
- Cropping image
- Resizing image
- Fitting image
- Changing quality of image
- Change width and height of image
- PHP >=7.1
- intervention/image ^2.4@dev
composer require ahp/thumbnail
Once installed you can use it
// Via helper function
img($path, $width, $height, $mode, $quality)
OR
// Via class
\Thumb\Thumb::make($path, $width, $height, $mode, $quality)
afterward thumbnail will be create in same directory of given path named thumbnail
- path : Path of image
string|required
- width : Desired width
int|null
- height : Desired height
int|null
- mode: one of
fit
orresize
orcrop
- quality : Quality of image
int|null = 100
// Using img() helper function
<img src="<?= img($path, $width, $height, $mode, $quality) ?>">
// Full example
<img src="<?= img('files/animals/koala.jpg', 500, 200, 'crop', 50) ?>">
// we can ommit width or height but one of them is required to calculate it from other one
<img src="<?= img('files/animals/koala.jpg', 500) ?>">
// OR
<img src="<?= img('files/animals/koala.jpg', null, 200) ?>">
PHP Thumbnail is licensed under the MIT License.
Copyright 2019 Amirhossein Pooladvand