Creating Images
Before you can perform image processing, you need to create an instance of Image. The Image object unifies the differences in GD and Imagick and holds all the pertinent info about the image. See Image Functions section for more info.
Editor Open
The common way of creating an image is by using the editor open method:
use Grafika\Grafika;
$editor = Grafika::createEditor();
$editor->open( $image, 'path/to/image.jpg');
Now $image holds an Image instance that you can pass along to editor methods:
//...
$editor->resizeExact( $image, 200, 100 );
//...
$editor->flip( $image, 'h' );
Grafika::createImage
If you dont have an editor instance, you can create an image directly:
use Grafika\Grafika;
$image = Grafika::createImage('path/to/image.jpg');
Blank Image
You can also create a blank image:
use Grafika\Grafika;
$image = Grafika::createBlankImage(100,100);
Making a Copy
Creating a copy of an image is as easy as using the clone keyword:
$copy = clone $image;
Now $copy is independent of the changes you will make in $image. You can leverage this functionality to easily make a backup:
//...
$backup = clone $image; // Full copy
$editor->crop( $image, 100, 100 ); // Crop it
$editor->save( $image, 'cropped.jpg' ); // Cropped version
$editor->save( $backup, 'original.jpg' ); // Unaffected by crop version