1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-29 08:40:33 +02:00

Fix bug with drawing (half) transparent colors with GD

This commit is contained in:
Oliver Vogel
2023-12-20 16:31:52 +01:00
parent 1831a4f45e
commit 27833d225c
5 changed files with 9 additions and 0 deletions

View File

@@ -15,6 +15,8 @@ class DrawEllipseModifier extends AbstractDrawModifier
{
foreach ($image as $frame) {
if ($this->drawable->hasBorder()) {
imagealphablending($frame->native(), true);
// slightly smaller ellipse to keep 1px bordered edges clean
if ($this->drawable->hasBackgroundColor()) {
imagefilledellipse(
@@ -49,6 +51,7 @@ class DrawEllipseModifier extends AbstractDrawModifier
)
);
} else {
imagealphablending($frame->native(), true);
imagefilledellipse(
$frame->native(),
$this->position()->x(),

View File

@@ -16,6 +16,7 @@ class DrawLineModifier extends AbstractDrawModifier
public function apply(ImageInterface $image): ImageInterface
{
foreach ($image as $frame) {
imagealphablending($frame->native(), true);
imageantialias($frame->native(), true);
imageline(
$frame->native(),

View File

@@ -19,6 +19,7 @@ class DrawPixelModifier extends DriverSpecializedModifier
);
foreach ($image as $frame) {
imagealphablending($frame->native(), true);
imagesetpixel(
$frame->native(),
$this->position->x(),

View File

@@ -19,6 +19,7 @@ class DrawPolygonModifier extends AbstractDrawModifier
{
foreach ($image as $frame) {
if ($this->drawable->hasBackgroundColor()) {
imagealphablending($frame->native(), true);
imagefilledpolygon(
$frame->native(),
$this->drawable->toArray(),
@@ -29,6 +30,7 @@ class DrawPolygonModifier extends AbstractDrawModifier
}
if ($this->drawable->hasBorder()) {
imagealphablending($frame->native(), true);
imagesetthickness($frame->native(), $this->drawable->borderSize());
imagepolygon(
$frame->native(),

View File

@@ -21,6 +21,7 @@ class DrawRectangleModifier extends AbstractDrawModifier
foreach ($image as $frame) {
// draw background
if ($this->drawable->hasBackgroundColor()) {
imagealphablending($frame->native(), true);
imagefilledrectangle(
$frame->native(),
$this->position()->x(),
@@ -35,6 +36,7 @@ class DrawRectangleModifier extends AbstractDrawModifier
// draw border
if ($this->drawable->hasBorder()) {
imagealphablending($frame->native(), true);
imagesetthickness($frame->native(), $this->drawable->borderSize());
imagerectangle(
$frame->native(),