image icon indicating copy to clipboard operation
image copied to clipboard

drawLine() ignores line width with GD <= 2.1.0

Open anhao opened this issue 1 year ago • 2 comments

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

  • PHP Version: PHP 8.1.25 (cli)
  • OS: windows
  • Intervention Image Version: v3.4.0
  • GD or Imagick: GD
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
···

anhao avatar Feb 29 '24 04:02 anhao

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

  • PHP Version: PHP 8.3.2
  • OS: MacOS
  • Intervention Image Version: 3.4.0
  • GD or Imagick: GD
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

olivervogel avatar Feb 29 '24 15:02 olivervogel

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

anhao avatar Mar 01 '24 03:03 anhao