Download the PHP package ognistyi/simpleimage without Composer
On this page you can find all versions of the php package ognistyi/simpleimage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package simpleimage
The SimpleImage PHP class
By Cory LaViska for A Beautiful Site, LLC (http://www.abeautifulsite.net/)
Licensed under the MIT license: http://opensource.org/licenses/MIT
Overview
This class makes image manipulation in PHP as simple as possible. The examples are the best way to learn how to use it, but here it is in a nutshell:
The two lines inside the try block load image.jpg, flip it horizontally, rotate it 90 degrees clockwise, shrink it to fit within a 320x200 box, apply a sepia effect, convert it to a GIF, and save it to result.gif.
With this class, you can effortlessly:
- Resize images (free resize, resize to width, resize to height, resize to fit)
- Crop images
- Flip/rotate/adjust orientation
- Adjust brightness & contrast
- Desaturate, colorize, pixelate, blur, etc.
- Overlay one image onto another (watermarking)
- Add text using a font of your choice
- Convert between GIF, JPEG, and PNG formats
- Strip EXIF data
Requirements
This class requires PHP 5.3 and PHP GD library.
Usage
Loading
You can load an image when you instantiate a new SimpleImage object:
Or you can create empty image 200x100 with black background:
Saving
Images must be saved after you manipulate them. To save your changes to the original file, simply call:
Alternatively, you can specify a new filename:
You can specify quality as a second parameter in percents within range 0-100
Converting Between Formats
When saving, the resulting image format is determined by the file extension. For example, you can convert a JPEG to a GIF by doing this:
Stripping EXIF data
There is no built-in method for stripping EXIF data, partly because there is currently no way to prevent EXIF data from being stripped using the GD library. However, you can easily strip EXIF data simply by loading and saving:
Method Chaining
SimpleImage supports method chaining, so you can make multiple changes and save the resulting image with just one line of code:
You can chain all of the methods below as well methods above.
Error Handling
SimpleImage throws exceptions when things don't work right. You should always load/manipulate/save images inside of a try/catch block to handle them properly:
Method Examples
Most methods have intelligent defaults so you don't need to pass in every argument. Check out SimpleImage.class.php for required/optional parameters and valid ranges for certain arguments.
- Valid positions are center, top, right, bottom, left, top left, top right, bottom left, bottom right
Utility Methods
The following methods are not chainable, because they return information about the image you're working with or output the image directly to the browser:
All versions of simpleimage with dependencies
ext-gd Version *