php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80369 getVectorGraphics () does not return an SVG-compatible string
Submitted: 2020-11-14 16:01 UTC Modified: 2020-12-16 13:01 UTC
From: lee dot traynor at skeptic dot de Assigned: danack (profile)
Status: Assigned Package: imagick (PECL)
PHP Version: 7.4.12 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 - 12 = ?
Subscribe to this entry?

 
 [2020-11-14 16:01 UTC] lee dot traynor at skeptic dot de
Description:
------------
---
From manual page: https://php.net/imagickdraw.getvectorgraphics
---
"Returns a string which specifies the vector graphics"

However, the string returned, although a legal XML object, is not compatible with SVG.

Test script:
---------------
$draw = new ImagickDraw ();
$draw->setStrokeColor ("red");
$draw->setFillColor ("none");
$draw->rectangle (10, 10, 100, 100);
$doc = new DOMDocument ("1.0", "UTF-8");
$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$doc->loadXML ($draw->getVectorGraphics ());
file_put_contents ("test_5.svg", $doc->saveXML ());

Expected result:
----------------
<?xml version="1.0"?>
<svg>
  <rect x="10" y="10" stroke="#FF0000" fill="#000000" fill-opacity="0" width="90" height="90" />
</svg>

Actual result:
--------------
<?xml version="1.0"?>
<drawing-wand>
  <clip-path/>
  <clip-units>Undefined</clip-units>
  <decorate>None</decorate>
  <encoding/>
  <fill>#00000000</fill>
  <fill-opacity>0</fill-opacity>
  <fill-rule>Evenodd</fill-rule>
  <font/>
  <font-family/>
  <font-size>12</font-size>
  <font-stretch>Undefined</font-stretch>
  <font-style>Undefined</font-style>
  <font-weight>0</font-weight>
  <gravity>Undefined</gravity>
  <stroke>#FF0000</stroke>
  <stroke-antialias>1</stroke-antialias>
  <stroke-dasharray/>
  <stroke-dashoffset>0</stroke-dashoffset>
  <stroke-linecap>Butt</stroke-linecap>
  <stroke-linejoin>Miter</stroke-linejoin>
  <stroke-miterlimit>10</stroke-miterlimit>
  <stroke-opacity>1</stroke-opacity>
  <stroke-width>1</stroke-width>
  <text-align>Undefined</text-align>
  <text-antialias>1</text-antialias>
  <text-undercolor>#000000</text-undercolor>
  <vector-graphics>stroke '#FFFF00000000'
fill 'none'
rectangle 10 10 100 100
</vector-graphics>
</drawing-wand>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-15 13:20 UTC] cmb@php.net
-Assigned To: +Assigned To: danack
 [2020-12-15 13:20 UTC] cmb@php.net
> However, the string returned, although a legal XML object, is
> not compatible with SVG.

As far as I know, it is not supposed to be SVG.  Dan, can you
confirm?  If so, please assign back to me as documentation
problem.
 [2020-12-16 13:01 UTC] danack@php.net
Actually, I don't know.

I did spend some time before trying to figure it out, and it's one of those things that made me had to limit how much time I spend investigating instability around the underlying ImageMagick API's.

If I recall correctly (and only like 60% chance) the output depended either on which version of ImageMagick was used, or which svg renderer ImageMagick was compiled with; either Inkscape if it's available, or their own proprietary svg renderer.

The documentation is vague:
https://imagemagick.org/api/drawing-wand.php#DrawGetVectorGraphics

The behaviour between DrawGetVectorGraphics and DrawSetVectorGraphics has had........."excitingly dynamic stability" for a while: https://www.imagemagick.org/discourse-server/viewtopic.php?t=27751
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC