-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imagesetthickness() in DrawLineModifier has no effect in certain environments #1298
Comments
That's really strange. Unfortunately, I can't reproduce it right now. According to a very old comment in the PHP documentation, the function |
@olivervogel Thanks for this response. THAT ACTUALLY FIXES THE PROBLEM! Is there a way for me to override this one function? I tried to just override that one class, but it's buried so deep inside Image Intervention that my override was not being recognized. Thank you for your help! |
1 similar comment
@olivervogel Thanks for this response. THAT ACTUALLY FIXES THE PROBLEM! Is there a way for me to override this one function? I tried to just override that one class, but it's buried so deep inside Image Intervention that my override was not being recognized. Thank you for your help! |
On the one hand, this is good news. On the other hand, it is also bad news, as the current implementation does not seem to work on certain systems. What particularly surprises me is that I can't detect any problems and I'm even using the same setup (MacOS, PHP 8.3.2, GD). And it is not really clear what triggers the behavior and how to handle this. As a quick solution for the moment, I would suggest to use a custom modifier that replicates the function of the It could look like this: use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\Interfaces\ImageInterface;
class DrawPixelLine implements ModifierInterface
{
public function __construct(
protected int $fromX,
protected int $fromY,
protected int $toX,
protected int $toY,
protected mixed $color,
protected int $width
) {
}
public function apply(ImageInterface $image): ImageInterface
{
$lineColor = $image->driver()->colorProcessor($image->colorspace())->colorToNative(
$image->driver()->handleInput($this->color)
);
foreach ($image as $frame) {
imagealphablending($frame->native(), true);
imagesetthickness($frame->native(), $this->width);
imageline(
$frame->native(),
$this->fromX,
$this->fromY,
$this->toX,
$this->toY,
$lineColor
);
}
return $image;
}
}
// apply modifier
$image->modify(new DrawPixelLine(10, 20, 130, 200, 'ff00ff', 3)); I'm sorry that I can't offer you a better solution at the moment. |
@olivervogel wow - thank you for all the great information. After some further research on my end, I am pretty sure this has something to do with my system, not your code. One of my co-workers pulled my code to his machine (actually a windows box running Sail) and everything worked as expected. I've been trying to get Laravel Herd to work successfully so my guess is something in that process caused this issue. I'm going to say thank you (big time!) and close this - I don't think you need to spend any more time on it unless someone else encounters the same thing. |
Describe the bug
The
width
parameter for thedrawLine
method was implemented in v 3.3.3. It worked correctly upon upgrade. For reasons unknown, it has stopped working and all drawn lines are 1 px, no matter what thewidth
parameter is. This is so effing weird!Code Example
Expected behavior
In the above example,
$width
was set to 4 (and verified by ray()) - image produced has a 1 px lineImages
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: