php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65895 ImagickDraw line opacity doesn't work
Submitted: 2013-10-14 17:14 UTC Modified: 2013-12-03 12:53 UTC
From: mail at jdborg dot com Assigned: mkoppanen (profile)
Status: Not a bug Package: imagick (PECL)
PHP Version: Irrelevant OS: CentOS 6.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at jdborg dot com
New email:
PHP Version: OS:

 

 [2013-10-14 17:14 UTC] mail at jdborg dot com
Description:
------------
I thought this was a legacy problem, but updated Imagick to 3.1.2 and ImageMagic to 6.8.7-0 2013-10-11 Q16.

When trying to draw a line on an image, opacity is ignored.

Test script:
---------------
$draw = new ImagickDraw();
$draw->setStrokeWidth(1);
$draw->setStrokeOpacity(0.5);
$draw->setStrokeColor(new ImagickPixel('#323232'));
$draw->line(0, 0, 10, 10);

Expected result:
----------------
A 50% opacity line is drawn.

Actual result:
--------------
A fully opaque line is drawn.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-15 13:16 UTC] mail at jdborg dot com
Full test:
$draw = new ImagickDraw();
$draw->setStrokeWidth(1);
$draw->setStrokeOpacity(0.1);
$draw->setStrokeColor("black");
$draw->line(0, 0, 500, 500);

$drawing = new Imagick();
$drawing->newImage(500, 500, "red");
$drawing->setImageFormat("png");
$drawing->drawImage($draw);

header("Content-Disposition: attachment; filename=test.png");
echo $drawing->getImageBlob();

The line should be barely visible.
 [2013-10-19 15:14 UTC] Danack at basereality dot com
This is not a bug. There are two issues with your code

i) You also need to set the fill color for a line stroke, not just the stroke color. Lines are drawn with a fill width of 1 pixel.

ii) Setting the color overwrites the opacity, as the color 'black' has it's opacity set to fully opaque. Switching the order of the commands, stops the opacity being changed by the set color command.

i.e. the setStrokeOpacity modifies the strokes colour. It does not get batched up and modify the draw command.
 [2013-12-03 11:28 UTC] mike@php.net
-Assigned To: +Assigned To: mkoppanen
 [2013-12-03 12:53 UTC] mkoppanen@php.net
-Status: Assigned +Status: Not a bug
 [2013-12-03 12:53 UTC] mkoppanen@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 22:01:28 2024 UTC