|
| 1 | +# Glide |
| 2 | + |
| 3 | +The purpose of this library is to offer extremely easy image manipulation in a similar fashion to cloud image processing services like [Imgix](http://www.imgix.com/) and [Cloudinary](http://cloudinary.com/). |
| 4 | + |
| 5 | +## Highlights |
| 6 | + |
| 7 | +- Adjust, resize and add effects to images using a simple URL based API. |
| 8 | +- Manipulated images are automatically cached and served with far-future expires headers. |
| 9 | +- Create your own image processing server or integrate directly into your app. |
| 10 | +- Supports the [GD Library](http://php.net/manual/en/book.image.php) and [Imagick PHP extension](http://php.net/manual/en/book.imagick.php). |
| 11 | +- Ability to secure image URLs using a private signing key. |
| 12 | +- Works with many different file systems, using the [Flysystem](http://flysystem.thephpleague.com/) library. |
| 13 | +- Powered by the [Intervention Image](http://image.intervention.io/) image handling and manipulation library. |
| 14 | + |
| 15 | +## The API |
| 16 | + |
| 17 | +- **Width** `w` |
| 18 | + - The width in pixels of the output image. |
| 19 | + - Example: `image.jpg?w=300` |
| 20 | +- **Height** `h` |
| 21 | + - The height in pixels of the output image. |
| 22 | + - Example: `image.jpg?h=300` |
| 23 | +- **Fit** `fit` |
| 24 | + - Controls how the output image is fitted to its target dimensions. |
| 25 | + - Accepts: `clip`, `scale`, `crop` |
| 26 | + - Example: `image.jpg?w=300&fit=crop` |
| 27 | +- **Rectangle** `rect` |
| 28 | + - Crops an image to specific dimensions. |
| 29 | + - Example: `image.jpg?rect=100,100,25,90` |
| 30 | +- **Crop Position** `crop` |
| 31 | + - Controls how the input image is aligned when the `fit` parameter is set to `crop`. |
| 32 | + - Accepts: `top-left`, `top`, `top-right`, `left`, `center`, `right`, `bottom-left`, `bottom`, `bottom-right` |
| 33 | + - Example: `image.jpg?rect=100,100,25,90` |
| 34 | +- **Orientation** `orient` |
| 35 | + - Rotates an image by supplied angle. |
| 36 | + - By default it uses Exif data to automatically orient images correctly. |
| 37 | + - Example: `image.jpg?orient=90` |
| 38 | +- **Brightness** `bri` |
| 39 | + - Adjusts the image brightness. |
| 40 | + - Use values between `-100` and `+100`. |
| 41 | + - Example: `image.jpg?bri=50` |
| 42 | +- **Contrast** `con` |
| 43 | + - Adjusts the image contrast. |
| 44 | + - Use values between `-100` for min. contrast, `0` for no change and `+100` for max. contrast. |
| 45 | + - Example: `image.jpg?con=50` |
| 46 | +- **Gamma** `gam` |
| 47 | + - Adjusts the image gamma. |
| 48 | + - Example: `image.jpg?gam=1.6` |
| 49 | +- **Blur** `blur` |
| 50 | + - Blurs an image by supplied blur strength. |
| 51 | + - Use values between `0` and `100`. |
| 52 | + - Example: `image.jpg?blur=15` |
| 53 | + |
| 54 | +## Example |
| 55 | + |
| 56 | +```php |
| 57 | +use Aws\S3\S3Client; |
| 58 | +use League\Flysystem\Adapter\AwsS3 as S3Adapter; |
| 59 | +use League\Flysystem\Adapter\Local as LocalAdapter; |
| 60 | +use League\Flysystem\Filesystem; |
| 61 | + |
| 62 | +// Connect to S3 account |
| 63 | +$s3Client = S3Client::factory([ |
| 64 | + 'key' => 'your-key', |
| 65 | + 'secret' => 'your-secret', |
| 66 | +]); |
| 67 | + |
| 68 | +// Setup server and define source and cache |
| 69 | +$glide = new Glide\Server( |
| 70 | + new Filesystem(new S3Adapter($s3Client, 'bucket-name')), |
| 71 | + new Filesystem(new LocalAdapter('cache-folder')) |
| 72 | +); |
| 73 | + |
| 74 | +// Enable private URLs |
| 75 | +$glide->setSignKey('your-signing-key'); |
| 76 | + |
| 77 | +// Output Image |
| 78 | +$glide->output( |
| 79 | + $request->getPathInfo(), |
| 80 | + $request->query->all() |
| 81 | +); |
| 82 | +``` |
0 commit comments