Migration from 1.x
The following are the changes from 1.x to version 2.x
Backward Incompatible Changes
Editor Functions and Image instance
The Editor API now passes the reference to an Image instance on every editor functions. Previously the Image instance is stored internally when
open is called.
Previously in version 1.x:
use Grafika\Grafika; $editor = Grafika::createEditor(); // Open image and assign it internally $editor->open( "path/to/jpeg/image.jpg" ); // Do something to the image and save it $editor->resize( 200, 200 ); $editor->save( "path/to/edited.jpg" );
Now in version 2.x:
use Grafika\Grafika; $editor = Grafika::createEditor(); // Open image and assign it to $image variable $editor->open( $image, "path/to/jpeg/image.jpg" ); // Do something to the image and save it. We pass the $image reference to the editor functions $editor->resize( $image, 200, 200 ); $editor->save( $image, "path/to/edited.jpg" );
The code is more verbose, but it actually has advantages:
- Editor functions are now self-contained since the input are passed in the parameters, not in an internal class variable. This prevent unintended side effects.
- Editor functions can now be used inside the editor itself without creating a new Editor instance.
- Its clear what Image instance you are editing at the moment.
Affected Editor functions:
Removed Editor Functions
- getImage - There is no need to store the Image internally.
- setImage - The same with getImage.
- blank - Use Grafika::createBlankImage instead.
- overlay - Functionality overlaps with blend. Use blend instead.