Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bartko-s/stefano-image
PHP image resizer
https://github.com/bartko-s/stefano-image
Last synced: 5 days ago
JSON representation
PHP image resizer
- Host: GitHub
- URL: https://github.com/bartko-s/stefano-image
- Owner: bartko-s
- Created: 2013-06-09T15:18:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-10-01T10:31:58.000Z (over 2 years ago)
- Last Synced: 2024-12-10T07:50:59.470Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 1.48 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Stefano Image
=============[![Build Status](https://app.travis-ci.com/bartko-s/stefano-image.svg?branch=master)](https://app.travis-ci.com/bartko-s/stefano-image)
[![Coverage Status](https://coveralls.io/repos/bartko-s/stefano-image/badge.png?branch=master)](https://coveralls.io/r/bartko-s/stefano-image?branch=master)Features
--------
- Resize and save image
- Add watermark
- Supported input and output format jpg, png, gifDependencies
------------
- php GD2 extensionInstalation using Composer
--------------------------
1. Run command ``` composer require stefano/stefano-image ```Usage
-----This is the original image
- resize and keep source image aspect ration
```
$maxWidth = 200;
$maxHeight = 200;
$resizer = new \StefanoImage\Image();
$resizer->sourceImage($sourceImage)
->resize($maxWidth, $maxHeight)
->save($outputDir, $name);
```This is the output
- adaptive resize
```
$width = 200;
$height = 50;
$resizer = new \StefanoImage\Image();
$resizer->sourceImage($sourceImage)
->adaptiveResize($width, $height)
->save($outputDir, $name);
```This is the output
- pad
```
$width = 200;
$height = 200;
$resizer = new \StefanoImage\Image();
$resizer->sourceImage($sourceImage)
->pad($width, $height)
->save($outputDir, $name);
```This is the output
- pad and change background color
```
$width = 350;
$height = 150;
$resizer = new \StefanoImage\Image();
$resizer->sourceImage($sourceImage)
->pad($width, $height)
->backgroundColor(35, 210, 240)
->save($outputDir, $name);
```This is the output
- add watermark
```
$maxWidth = 350;
$maxHeight = 150;
$maxWidthPercent = 40;
$maxHeightPercent = 40;
$opacity = 30;
$watermarkPosition = \StefanoImage\Image::WATERMARK_POSITION_TOP_RIGHT;
$resizer = new \StefanoImage\Image();
$resizer->sourceImage($sourceImage)
->resize($maxWidth, $maxHeight)
->addWatermark($watermark, $maxWidthPercent, $maxHeightPercent, $opacity, $watermarkPosition)
->save($outputDir, $name);
```This is the output
- change output format
```
$resizer->outputFormat(\StefanoImage\Image::OUTPUT_FORMAT_PNG);
```- change output quality
```
$resizer->quality(15);
```