image icon indicating copy to clipboard operation
image copied to clipboard

Collection of breaking change ideas for next major version

Open olivervogel opened this issue 1 year ago • 10 comments

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.

olivervogel avatar Aug 11 '24 11:08 olivervogel

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~~.

olivervogel avatar Oct 26 '24 14:10 olivervogel

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);

olivervogel avatar Oct 26 '24 14:10 olivervogel

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();

olivervogel avatar Dec 06 '24 07:12 olivervogel

Rename Image::blendTransparency() to Image::background()

Could be shorter and more handy.

olivervogel avatar Jan 05 '25 09:01 olivervogel

Add DriverInterface::version(): string

Could be useful to read out the version of the underlying image library.

$version = Driver::version(); // "1.2.3"

olivervogel avatar Jan 10 '25 17:01 olivervogel

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

olivervogel avatar Jan 20 '25 15:01 olivervogel

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
}

olivervogel avatar Feb 04 '25 15:02 olivervogel

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.

olivervogel avatar Mar 22 '25 08:03 olivervogel

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.

ADmad avatar Mar 22 '25 09:03 ADmad

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.

olivervogel avatar Jun 12 '25 06:06 olivervogel