gradientUnits="userSpaceOnUse" rendered incorrectly

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Socob
Posts: 1
Joined: 2017-02-04T18:28:40-07:00
Authentication code: 1151

gradientUnits="userSpaceOnUse" rendered incorrectly

Post by Socob »

It seems this bug in Inkscape (“gradientUnits userSpaceOnUse using wrong viewport”) affects ImageMagick in much the same way. To quote from that bug report:
When a gradient uses gradientUnits="userSpaceOnUse" the values of the gradient vector (x1,y1,x2,y1) are rendered using the wrong viewport. It seems the same viewport is used as if gradientUnits="objectBoundingBox" was set.

Therefore when specifying the gradient vector using percentages of the viewport, the SVG is rendered wrongly.

See the testcases for details.
– testcase1 specifies a linear gradient with <linearGradient gradientUnits="userSpaceOnUse" x2="1">.
– testcase2 specifies a linear gradient with <linearGradient gradientUnits="userSpaceOnUse" x2="100%">. x2 could be left out here however since 100% is the default.

As long as the viewport doesn't extend from (0,0) to (1,1) – the testcase should have a viewport from (0,0) to (256,256) – those gradients should render differently.
The test cases mentioned are the following:
  1. testcase 1 using <linearGradient gradientUnits="userSpaceOnUse" x2="1">
  2. testcase 2 using <linearGradient gradientUnits="userSpaceOnUse" x2="100%">
Also note my comment on that bug:
For what it’s worth, all of the following programs disagree with Inkscape (i.e. do not render the same image for test cases 1 and 2):
– Firefox
– Chromium
– GIMP
– Eye of GNOME
– GPicView
(ImageMagick, on the other hand, seems to follow Inkscape’s behavior…)

So at least from an “implementations defining standards” point of view, it seems pretty clear that Inkscape’s behavior is wrong.
How to reproduce: Open both test cases linked above using ImageMagick, e.g.:

Code: Select all

display testcase1.svg
display testcase2.svg
Both images yield the same output, even though they should not.

Version information (running on Ubuntu 16.04.1):

Code: Select all

display --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
Perhaps this issue is related: percentage in SVG-TEXT?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: gradientUnits="userSpaceOnUse" rendered incorrectly

Post by snibgo »

It would help if you stated which delegate in your tests IM used to render the SVG. If it used Inkscape, then of course IM would do what Inkscape does. But the delegate might have been MVG or RSVG.
snibgo's IM pages: im.snibgo.com
Post Reply