Collection of breaking change ideas for next major version
Collection of ideas that would be nice to have but would introduce a BC and would therefore only be possible in the next major version.
Please note that this is an initial collection of ideas that may or may not be adopted.
Standardization and simplification of offset parameters
To specify parameters for offsets, offset_x and offset_y are used in v3. The names could be catchier and simpler.
For example, just x or left instead of ~~offset_x~~ and y or top instead of ~~offset_y~~.
More universal ColorInterface::create() method
Currently only string values of the colors are processed. It would also be nice if the values of the color channels could be specified directly.
use Intervention\Image\Colors\Rgb\Color;
// currently
$color = Color::create('rgb(255, 255, 255)');
// more universal
$color = Color::create('rgb(255, 255, 255)');
$color = Color::create(255, 255, 255);
Switch to dedicated methods for reading
The universal method for reading images ImageManager::read() is convenient and has many advantages. However, it also has disadvantages compared to a group of specialised methods for each type of input. A change can be discussed.
// before
ImageManager::read();
// after
ImageManager::imageFromFilePath();
ImageManager::imageFromBinary();
ImageManager::imageFromBase64();
ImageManager::imageFromDataUri();
ImageManager::imageFromStream();
ImageManager::imageFromSplFileInfo();
Rename Image::blendTransparency() to Image::background()
Could be shorter and more handy.
Add DriverInterface::version(): string
Could be useful to read out the version of the underlying image library.
$version = Driver::version(); // "1.2.3"
Image on-demand-evaluation
Conversion to so-called on-demand evaluation of image objects. This means that image objects are only loaded internally into the memory when they are actually needed. Before that, they are simply a sequence of commands.
Example:
$image = ImageManager::withDriver($classname)
->read('image.jpg') // call delayed and saved in stack: no real image
->resize(300, 200) // call delayed and saved in stack: no real image
->brightness(10) // call delayed and saved in stack: no real image
->contrast(5) // call delayed and saved in stack: no real image
->sharpen() // call delayed and saved in stack: no real image
->toPng(); // Image only becomes real at this point: Stack is evaluated completely
Replace string defined mime types with MediaType enum
Example:
interface EncodedImageInterface extends FileInterface
{
public function mimetype(): string; // no
}
interface EncodedImageInterface extends FileInterface
{
public function mimetype(): MediaType; // yes
}
Leave default values for background colors undefined and use “blending color”
Currently there are default values “ffffff” for background colors for Image::pad(), Image::contain(), Image::crop(), Image::resizeCanvas() and Image::resizeCanvasRelative().
I think it makes more logical sense to leave these undefined with null by default and use the blending color in that case (if no color is specified).
The name “blending color” should be discussed for renaming if necessary.
Conversion to so-called on-demand evaluation of image objects. This means that image objects are only loaded internally into the memory when they are actually needed. Before that, they are simply a sequence of commands
I very much like this idea.
Drawing only on certain channels
Currently, for example, it is only possible to draw all color channels with drawPixel(). It would be ideal to select only certain color channels, e.g. to write only on the alpha channel and make areas transparent.