mirror of
https://github.com/Intervention/image.git
synced 2025-08-21 05:01:20 +02:00
Rename Image::blendTransparency() to Image::background()
This commit is contained in:
9
changelog.md
Normal file
9
changelog.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
## New Features
|
||||||
|
|
||||||
|
- ImageInterface::version()
|
||||||
|
|
||||||
|
## API Changes
|
||||||
|
|
||||||
|
- ImageInterface::blendTransparency() was renamed to ImageInterface::background()
|
||||||
|
- ImageInterface::setBlendingColor() was renamed to ImageInterface::setBackgroundColor()
|
||||||
|
- ImageInterface::blendingColor() was renamed to ImageInterface::backgroundColor()
|
@@ -16,7 +16,7 @@ class Config
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
public bool $autoOrientation = true,
|
public bool $autoOrientation = true,
|
||||||
public bool $decodeAnimation = true,
|
public bool $decodeAnimation = true,
|
||||||
public mixed $blendingColor = 'ffffff',
|
public mixed $backgroundColor = 'ffffff',
|
||||||
public bool $strip = false,
|
public bool $strip = false,
|
||||||
) {
|
) {
|
||||||
//
|
//
|
||||||
|
@@ -19,13 +19,13 @@ class JpegEncoder extends GenericJpegEncoder implements SpecializedInterface
|
|||||||
*/
|
*/
|
||||||
public function encode(ImageInterface $image): EncodedImage
|
public function encode(ImageInterface $image): EncodedImage
|
||||||
{
|
{
|
||||||
$blendingColor = $this->driver()->handleInput(
|
$backgroundColor = $this->driver()->handleInput(
|
||||||
$this->driver()->config()->blendingColor
|
$this->driver()->config()->backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
$output = Cloner::cloneBlended(
|
$output = Cloner::cloneBlended(
|
||||||
$image->core()->native(),
|
$image->core()->native(),
|
||||||
background: $blendingColor
|
background: $backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->createEncodedImage(function ($pointer) use ($output): void {
|
return $this->createEncodedImage(function ($pointer) use ($output): void {
|
||||||
|
@@ -7,9 +7,9 @@ namespace Intervention\Image\Drivers\Gd\Modifiers;
|
|||||||
use Intervention\Image\Drivers\Gd\Cloner;
|
use Intervention\Image\Drivers\Gd\Cloner;
|
||||||
use Intervention\Image\Interfaces\ImageInterface;
|
use Intervention\Image\Interfaces\ImageInterface;
|
||||||
use Intervention\Image\Interfaces\SpecializedInterface;
|
use Intervention\Image\Interfaces\SpecializedInterface;
|
||||||
use Intervention\Image\Modifiers\BlendTransparencyModifier as GenericBlendTransparencyModifier;
|
use Intervention\Image\Modifiers\BackgroundModifier as GenericBackgroundModifier;
|
||||||
|
|
||||||
class BlendTransparencyModifier extends GenericBlendTransparencyModifier implements SpecializedInterface
|
class BackgroundModifier extends GenericBackgroundModifier implements SpecializedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -18,13 +18,13 @@ class BlendTransparencyModifier extends GenericBlendTransparencyModifier impleme
|
|||||||
*/
|
*/
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
$blendingColor = $this->blendingColor($this->driver());
|
$backgroundColor = $this->backgroundColor($this->driver());
|
||||||
|
|
||||||
foreach ($image as $frame) {
|
foreach ($image as $frame) {
|
||||||
// create new canvas with blending color as background
|
// create new canvas with background color as background
|
||||||
$modified = Cloner::cloneBlended(
|
$modified = Cloner::cloneBlended(
|
||||||
$frame->native(),
|
$frame->native(),
|
||||||
background: $blendingColor
|
background: $backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
// set new gd image
|
// set new gd image
|
@@ -28,12 +28,12 @@ class ContainModifier extends GenericContainModifier implements SpecializedInter
|
|||||||
$crop = $this->getCropSize($image);
|
$crop = $this->getCropSize($image);
|
||||||
$resize = $this->getResizeSize($image);
|
$resize = $this->getResizeSize($image);
|
||||||
$background = $this->driver()->handleInput($this->background);
|
$background = $this->driver()->handleInput($this->background);
|
||||||
$blendingColor = $this->driver()->handleInput(
|
$backgroundColor = $this->driver()->handleInput(
|
||||||
$this->driver()->config()->blendingColor
|
$this->driver()->config()->backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($image as $frame) {
|
foreach ($image as $frame) {
|
||||||
$this->modify($frame, $crop, $resize, $background, $blendingColor);
|
$this->modify($frame, $crop, $resize, $background, $backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
@@ -47,7 +47,7 @@ class ContainModifier extends GenericContainModifier implements SpecializedInter
|
|||||||
SizeInterface $crop,
|
SizeInterface $crop,
|
||||||
SizeInterface $resize,
|
SizeInterface $resize,
|
||||||
ColorInterface $background,
|
ColorInterface $background,
|
||||||
ColorInterface $blendingColor
|
ColorInterface $backgroundColor
|
||||||
): void {
|
): void {
|
||||||
// create new gd image
|
// create new gd image
|
||||||
$modified = Cloner::cloneEmpty($frame->native(), $resize, $background);
|
$modified = Cloner::cloneEmpty($frame->native(), $resize, $background);
|
||||||
@@ -56,9 +56,9 @@ class ContainModifier extends GenericContainModifier implements SpecializedInter
|
|||||||
// even if background-color is set
|
// even if background-color is set
|
||||||
$transparent = imagecolorallocatealpha(
|
$transparent = imagecolorallocatealpha(
|
||||||
$modified,
|
$modified,
|
||||||
$blendingColor->channel(Red::class)->value(),
|
$backgroundColor->channel(Red::class)->value(),
|
||||||
$blendingColor->channel(Green::class)->value(),
|
$backgroundColor->channel(Green::class)->value(),
|
||||||
$blendingColor->channel(Blue::class)->value(),
|
$backgroundColor->channel(Blue::class)->value(),
|
||||||
127,
|
127,
|
||||||
);
|
);
|
||||||
imagealphablending($modified, false); // do not blend / just overwrite
|
imagealphablending($modified, false); // do not blend / just overwrite
|
||||||
@@ -72,7 +72,7 @@ class ContainModifier extends GenericContainModifier implements SpecializedInter
|
|||||||
$transparent
|
$transparent
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy image from original with blending alpha
|
// copy image from original with background alpha
|
||||||
imagealphablending($modified, true);
|
imagealphablending($modified, true);
|
||||||
imagecopyresampled(
|
imagecopyresampled(
|
||||||
$modified,
|
$modified,
|
||||||
|
@@ -36,13 +36,13 @@ class QuantizeColorsModifier extends GenericQuantizeColorsModifier implements Sp
|
|||||||
$this->driver()->handleInput($this->background)
|
$this->driver()->handleInput($this->background)
|
||||||
);
|
);
|
||||||
|
|
||||||
$blendingColor = $this->driver()->handleInput(
|
$backgroundColor = $this->driver()->handleInput(
|
||||||
$this->driver()->config()->blendingColor
|
$this->driver()->config()->backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($image as $frame) {
|
foreach ($image as $frame) {
|
||||||
// create new image for color quantization
|
// create new image for color quantization
|
||||||
$reduced = Cloner::cloneEmpty($frame->native(), background: $blendingColor);
|
$reduced = Cloner::cloneEmpty($frame->native(), background: $backgroundColor);
|
||||||
|
|
||||||
// fill with background
|
// fill with background
|
||||||
imagefill($reduced, 0, 0, $background);
|
imagefill($reduced, 0, 0, $background);
|
||||||
|
@@ -18,14 +18,14 @@ class JpegEncoder extends GenericJpegEncoder implements SpecializedInterface
|
|||||||
{
|
{
|
||||||
$format = 'JPEG';
|
$format = 'JPEG';
|
||||||
$compression = Imagick::COMPRESSION_JPEG;
|
$compression = Imagick::COMPRESSION_JPEG;
|
||||||
$blendingColor = $this->driver()->handleInput(
|
$backgroundColor = $this->driver()->handleInput(
|
||||||
$this->driver()->config()->blendingColor
|
$this->driver()->config()->backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
// resolve blending color because jpeg has no transparency
|
// resolve background color because jpeg has no transparency
|
||||||
$background = $this->driver()
|
$background = $this->driver()
|
||||||
->colorProcessor($image->colorspace())
|
->colorProcessor($image->colorspace())
|
||||||
->colorToNative($blendingColor);
|
->colorToNative($backgroundColor);
|
||||||
|
|
||||||
// set alpha value to 1 because Imagick renders
|
// set alpha value to 1 because Imagick renders
|
||||||
// possible full transparent colors as black
|
// possible full transparent colors as black
|
||||||
|
@@ -7,18 +7,18 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers;
|
|||||||
use Imagick;
|
use Imagick;
|
||||||
use Intervention\Image\Interfaces\ImageInterface;
|
use Intervention\Image\Interfaces\ImageInterface;
|
||||||
use Intervention\Image\Interfaces\SpecializedInterface;
|
use Intervention\Image\Interfaces\SpecializedInterface;
|
||||||
use Intervention\Image\Modifiers\BlendTransparencyModifier as GenericBlendTransparencyModifier;
|
use Intervention\Image\Modifiers\BackgroundModifier as GenericBackgroundModifier;
|
||||||
|
|
||||||
class BlendTransparencyModifier extends GenericBlendTransparencyModifier implements SpecializedInterface
|
class BackgroundModifier extends GenericBackgroundModifier implements SpecializedInterface
|
||||||
{
|
{
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
$blendingColor = $this->blendingColor($this->driver());
|
$backgroundColor = $this->backgroundColor($this->driver());
|
||||||
|
|
||||||
// get imagickpixel from blending color
|
// get imagickpixel from background color
|
||||||
$pixel = $this->driver()
|
$pixel = $this->driver()
|
||||||
->colorProcessor($image->colorspace())
|
->colorProcessor($image->colorspace())
|
||||||
->colorToNative($blendingColor);
|
->colorToNative($backgroundColor);
|
||||||
|
|
||||||
// merge transparent areas with the background color
|
// merge transparent areas with the background color
|
||||||
foreach ($image as $frame) {
|
foreach ($image as $frame) {
|
@@ -57,7 +57,7 @@ use Intervention\Image\Interfaces\ProfileInterface;
|
|||||||
use Intervention\Image\Interfaces\ResolutionInterface;
|
use Intervention\Image\Interfaces\ResolutionInterface;
|
||||||
use Intervention\Image\Interfaces\SizeInterface;
|
use Intervention\Image\Interfaces\SizeInterface;
|
||||||
use Intervention\Image\Modifiers\AlignRotationModifier;
|
use Intervention\Image\Modifiers\AlignRotationModifier;
|
||||||
use Intervention\Image\Modifiers\BlendTransparencyModifier;
|
use Intervention\Image\Modifiers\BackgroundModifier;
|
||||||
use Intervention\Image\Modifiers\BlurModifier;
|
use Intervention\Image\Modifiers\BlurModifier;
|
||||||
use Intervention\Image\Modifiers\BrightnessModifier;
|
use Intervention\Image\Modifiers\BrightnessModifier;
|
||||||
use Intervention\Image\Modifiers\ColorizeModifier;
|
use Intervention\Image\Modifiers\ColorizeModifier;
|
||||||
@@ -406,24 +406,24 @@ final class Image implements ImageInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see ImageInterface::blendingColor()
|
* @see ImageInterface::backgroundColor()
|
||||||
*/
|
*/
|
||||||
public function blendingColor(): ColorInterface
|
public function backgroundColor(): ColorInterface
|
||||||
{
|
{
|
||||||
return $this->driver()->handleInput(
|
return $this->driver()->handleInput(
|
||||||
$this->driver()->config()->blendingColor
|
$this->driver()->config()->backgroundColor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see ImageInterface::setBlendingColor()
|
* @see ImageInterface::setBackgroundColor()
|
||||||
*/
|
*/
|
||||||
public function setBlendingColor(mixed $color): ImageInterface
|
public function setBackgroundColor(mixed $color): ImageInterface
|
||||||
{
|
{
|
||||||
$this->driver()->config()->setOptions(
|
$this->driver()->config()->setOptions(
|
||||||
blendingColor: $this->driver()->handleInput($color)
|
backgroundColor: $this->driver()->handleInput($color)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -432,11 +432,11 @@ final class Image implements ImageInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see ImageInterface::blendTransparency()
|
* @see ImageInterface::background()
|
||||||
*/
|
*/
|
||||||
public function blendTransparency(mixed $color = null): ImageInterface
|
public function background(mixed $color = null): ImageInterface
|
||||||
{
|
{
|
||||||
return $this->modify(new BlendTransparencyModifier($color));
|
return $this->modify(new BackgroundModifier($color));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -223,22 +223,25 @@ interface ImageInterface extends IteratorAggregate, Countable
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function blendingColor(): ColorInterface;
|
public function backgroundColor(): ColorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set blending color will have no effect unless image is converted into a format
|
* Set the background color to be used with self::background()
|
||||||
* which does not support transparency.
|
*
|
||||||
|
* Settting the background color will have no effect unless image is
|
||||||
|
* converted into a format which does not support transparency or
|
||||||
|
* self::background() is used.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function setBlendingColor(mixed $color): self;
|
public function setBackgroundColor(mixed $color): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace transparent areas of the image with given color
|
* Replace transparent areas of the image with given color
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function blendTransparency(mixed $color = null): self;
|
public function background(mixed $color = null): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve ICC color profile of image
|
* Retrieve ICC color profile of image
|
||||||
|
@@ -14,7 +14,7 @@ use Intervention\Image\Exceptions\RuntimeException;
|
|||||||
use Intervention\Image\Interfaces\ColorInterface;
|
use Intervention\Image\Interfaces\ColorInterface;
|
||||||
use Intervention\Image\Interfaces\DriverInterface;
|
use Intervention\Image\Interfaces\DriverInterface;
|
||||||
|
|
||||||
class BlendTransparencyModifier extends SpecializableModifier
|
class BackgroundModifier extends SpecializableModifier
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create new modifier object
|
* Create new modifier object
|
||||||
@@ -27,17 +27,17 @@ class BlendTransparencyModifier extends SpecializableModifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode blending color of current modifier with given driver. Possible
|
* Decode background color of current modifier with given driver. Possible
|
||||||
* (semi-)transparent alpha channel values are made opaque.
|
* (semi-)transparent alpha channel values are made opaque.
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws ColorException
|
* @throws ColorException
|
||||||
*/
|
*/
|
||||||
protected function blendingColor(DriverInterface $driver): ColorInterface
|
protected function backgroundColor(DriverInterface $driver): ColorInterface
|
||||||
{
|
{
|
||||||
// decode blending color
|
// decode background color
|
||||||
$color = $driver->handleInput(
|
$color = $driver->handleInput(
|
||||||
$this->color ?: $driver->config()->blendingColor
|
$this->color ?: $driver->config()->backgroundColor
|
||||||
);
|
);
|
||||||
|
|
||||||
// replace alpha channel value with opaque value
|
// replace alpha channel value with opaque value
|
@@ -18,12 +18,12 @@ final class ConfigTest extends BaseTestCase
|
|||||||
|
|
||||||
$this->assertTrue($config->autoOrientation);
|
$this->assertTrue($config->autoOrientation);
|
||||||
$this->assertTrue($config->decodeAnimation);
|
$this->assertTrue($config->decodeAnimation);
|
||||||
$this->assertEquals('ffffff', $config->blendingColor);
|
$this->assertEquals('ffffff', $config->backgroundColor);
|
||||||
|
|
||||||
$config = new Config(
|
$config = new Config(
|
||||||
autoOrientation: false,
|
autoOrientation: false,
|
||||||
decodeAnimation: false,
|
decodeAnimation: false,
|
||||||
blendingColor: 'f00',
|
backgroundColor: 'f00',
|
||||||
strip: true,
|
strip: true,
|
||||||
);
|
);
|
||||||
$this->assertInstanceOf(Config::class, $config);
|
$this->assertInstanceOf(Config::class, $config);
|
||||||
@@ -31,7 +31,7 @@ final class ConfigTest extends BaseTestCase
|
|||||||
$this->assertFalse($config->autoOrientation);
|
$this->assertFalse($config->autoOrientation);
|
||||||
$this->assertFalse($config->decodeAnimation);
|
$this->assertFalse($config->decodeAnimation);
|
||||||
$this->assertTrue($config->strip);
|
$this->assertTrue($config->strip);
|
||||||
$this->assertEquals('f00', $config->blendingColor);
|
$this->assertEquals('f00', $config->backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSetOptions(): void
|
public function testGetSetOptions(): void
|
||||||
@@ -40,35 +40,35 @@ final class ConfigTest extends BaseTestCase
|
|||||||
$this->assertTrue($config->autoOrientation);
|
$this->assertTrue($config->autoOrientation);
|
||||||
$this->assertTrue($config->decodeAnimation);
|
$this->assertTrue($config->decodeAnimation);
|
||||||
$this->assertFalse($config->strip);
|
$this->assertFalse($config->strip);
|
||||||
$this->assertEquals('ffffff', $config->blendingColor);
|
$this->assertEquals('ffffff', $config->backgroundColor);
|
||||||
|
|
||||||
$result = $config->setOptions(
|
$result = $config->setOptions(
|
||||||
autoOrientation: false,
|
autoOrientation: false,
|
||||||
decodeAnimation: false,
|
decodeAnimation: false,
|
||||||
blendingColor: 'f00',
|
backgroundColor: 'f00',
|
||||||
strip: true,
|
strip: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertFalse($config->autoOrientation);
|
$this->assertFalse($config->autoOrientation);
|
||||||
$this->assertFalse($config->decodeAnimation);
|
$this->assertFalse($config->decodeAnimation);
|
||||||
$this->assertEquals('f00', $config->blendingColor);
|
$this->assertEquals('f00', $config->backgroundColor);
|
||||||
|
|
||||||
$this->assertFalse($result->autoOrientation);
|
$this->assertFalse($result->autoOrientation);
|
||||||
$this->assertFalse($result->decodeAnimation);
|
$this->assertFalse($result->decodeAnimation);
|
||||||
$this->assertTrue($result->strip);
|
$this->assertTrue($result->strip);
|
||||||
$this->assertEquals('f00', $result->blendingColor);
|
$this->assertEquals('f00', $result->backgroundColor);
|
||||||
|
|
||||||
$result = $config->setOptions(blendingColor: '000');
|
$result = $config->setOptions(backgroundColor: '000');
|
||||||
|
|
||||||
$this->assertFalse($config->autoOrientation);
|
$this->assertFalse($config->autoOrientation);
|
||||||
$this->assertFalse($config->decodeAnimation);
|
$this->assertFalse($config->decodeAnimation);
|
||||||
$this->assertTrue($config->strip);
|
$this->assertTrue($config->strip);
|
||||||
$this->assertEquals('000', $config->blendingColor);
|
$this->assertEquals('000', $config->backgroundColor);
|
||||||
|
|
||||||
$this->assertFalse($result->autoOrientation);
|
$this->assertFalse($result->autoOrientation);
|
||||||
$this->assertFalse($result->decodeAnimation);
|
$this->assertFalse($result->decodeAnimation);
|
||||||
$this->assertTrue($result->strip);
|
$this->assertTrue($result->strip);
|
||||||
$this->assertEquals('000', $result->blendingColor);
|
$this->assertEquals('000', $result->backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetOptionsWithArray(): void
|
public function testSetOptionsWithArray(): void
|
||||||
@@ -77,17 +77,17 @@ final class ConfigTest extends BaseTestCase
|
|||||||
$result = $config->setOptions([
|
$result = $config->setOptions([
|
||||||
'autoOrientation' => false,
|
'autoOrientation' => false,
|
||||||
'decodeAnimation' => false,
|
'decodeAnimation' => false,
|
||||||
'blendingColor' => 'f00',
|
'backgroundColor' => 'f00',
|
||||||
'strip' => true,
|
'strip' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertFalse($config->autoOrientation);
|
$this->assertFalse($config->autoOrientation);
|
||||||
$this->assertFalse($config->decodeAnimation);
|
$this->assertFalse($config->decodeAnimation);
|
||||||
$this->assertTrue($config->strip);
|
$this->assertTrue($config->strip);
|
||||||
$this->assertEquals('f00', $config->blendingColor);
|
$this->assertEquals('f00', $config->backgroundColor);
|
||||||
$this->assertFalse($result->autoOrientation);
|
$this->assertFalse($result->autoOrientation);
|
||||||
$this->assertFalse($result->decodeAnimation);
|
$this->assertFalse($result->decodeAnimation);
|
||||||
$this->assertTrue($result->strip);
|
$this->assertTrue($result->strip);
|
||||||
$this->assertEquals('f00', $result->blendingColor);
|
$this->assertEquals('f00', $result->backgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -283,29 +283,29 @@ final class ImageTest extends GdTestCase
|
|||||||
$this->assertInstanceOf(Image::class, $this->image->text('test', 0, 0, new Font()));
|
$this->assertInstanceOf(Image::class, $this->image->text('test', 0, 0, new Font()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyDefault(): void
|
public function testBackgroundDefault(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 255, 255, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 255, 255, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 255, 255, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 255, 255, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyArgument(): void
|
public function testBackgroundArgument(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency('ff5500');
|
$result = $image->background('ff5500');
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyIgnoreTransparencyInBlendingColor(): void
|
public function testBackgroundIgnoreTransparencyInBackgroundColor(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency('ff550055');
|
$result = $image->background('ff550055');
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
@@ -277,29 +277,29 @@ final class ImageTest extends ImagickTestCase
|
|||||||
$this->assertInstanceOf(Image::class, $this->image->sharpen(12));
|
$this->assertInstanceOf(Image::class, $this->image->sharpen(12));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyDefault(): void
|
public function testBackgroundDefault(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 255, 255, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 255, 255, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 255, 255, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 255, 255, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyArgument(): void
|
public function testBackgroundArgument(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency('ff5500');
|
$result = $image->background('ff5500');
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlendTransparencyIgnoreTransparencyInBlendingColor(): void
|
public function testBackgroundIgnoreTransparencyInBackgroundColor(): void
|
||||||
{
|
{
|
||||||
$image = $this->readTestImage('gradient.gif');
|
$image = $this->readTestImage('gradient.gif');
|
||||||
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
$this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0));
|
||||||
$result = $image->blendTransparency('ff550055');
|
$result = $image->background('ff550055');
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0));
|
||||||
}
|
}
|
||||||
|
@@ -137,20 +137,20 @@ final class ImageManagerTestGd extends BaseTestCase
|
|||||||
$this->assertFalse($image->isAnimated());
|
$this->assertFalse($image->isAnimated());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApplyBlendingColorDefault(): void
|
public function testApplyBackgroundColorDefault(): void
|
||||||
{
|
{
|
||||||
$manager = new ImageManager(Driver::class);
|
$manager = new ImageManager(Driver::class);
|
||||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
|
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
|
||||||
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
|
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApplyBlendingColorConfigured(): void
|
public function testApplyBackgroundColorConfigured(): void
|
||||||
{
|
{
|
||||||
$manager = new ImageManager(Driver::class, blendingColor: 'ff5500');
|
$manager = new ImageManager(Driver::class, backgroundColor: 'ff5500');
|
||||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));
|
||||||
}
|
}
|
||||||
|
@@ -137,20 +137,20 @@ final class ImageManagerTestImagick extends BaseTestCase
|
|||||||
$this->assertFalse($image->isAnimated());
|
$this->assertFalse($image->isAnimated());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApplyBlendingColor(): void
|
public function testApplyBackgroundColor(): void
|
||||||
{
|
{
|
||||||
$manager = new ImageManager(Driver::class);
|
$manager = new ImageManager(Driver::class);
|
||||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
|
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
|
||||||
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
|
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApplyBlendingColorConfigured(): void
|
public function testApplyBackgroundColorConfigured(): void
|
||||||
{
|
{
|
||||||
$manager = new ImageManager(Driver::class, blendingColor: 'ff5500');
|
$manager = new ImageManager(Driver::class, backgroundColor: 'ff5500');
|
||||||
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
$image = $manager->read($this->getTestResourcePath('blocks.png'));
|
||||||
$result = $image->blendTransparency();
|
$result = $image->background();
|
||||||
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
|
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
|
||||||
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));
|
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user