Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.84k stars 1.5k forks source link

drawLine() ignores line width with GD <= 2.1.0 #1304

Open anhao opened 6 months ago

anhao commented 6 months ago

Describe the bug I am using Image v3.4.0 , I used drawLine to draw lines, it has always been 1px

The same result was obtained using the DrawPixelLine of https://github.com/Intervention/image/issues/1298

Code Example

$image->drawLine(function (LineFactory $line)use($listHeight) {
    $line->from(980, 20); // starting point of line
    $line->to(980, $listHeight-20); // ending point
    $line->color('#723e4b'); // color of line
    $line->width(5); // line width in pixels
});

Images test

Environment (please complete the following information):


gd

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.9.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.6.34
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30512
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
AVIF Support => enabled
TGA Read Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1
···
olivervogel commented 6 months ago

This is a really strange error that I can't really explain at the moment.

As described in #1298 and here, the width is apparently discarded when imageantialias() is activated. A workaround could be to use a custom modifier that works without the function but of course also has the disadvantage that the line is not antialiased. How this could work I already described here.

However, I am still wondering, because in my environment, I have no problems and everything works as expected. I can explain this by the fact that the bug was fixed at some point. I see that you are using GD version bundled (2.1.0 compatible).

I am currently running GD 2.3.3, maybe you can try to switch to this newer version as well.

My Environment

gd

GD Support => enabled
GD headers Version => 2.3.3
GD library Version => 2.3.3
FreeType Support => enabled
FreeType Linkage => with freetype
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XPM Support => enabled
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
AVIF Support => enabled
TGA Read Support => enabled
anhao commented 6 months ago

On linux, using gd 2.3.3 is possible , But in window the default gd version is 2.1.0