radial-gradient issue in mvg files

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
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

radial-gradient issue in mvg files

Post by rocastro »

I tried to draw a circle whith radial gradient. From the comand line no problem.

convert -size 1000x1000 xc:white -fill radial-gradient:"hsl(0,255,60)"-"hsl(0,255,120)" -draw "circle 500,500,500,750" draw_circle.png

When I put the command in a mvg file, then imagemagick crash whith unrecognized color ´radial-gradient´:

convert -size 1000x1000 xc:white -draw @draw_circle.mvg draw_circle.png

And the draw_circle.mvg file is:

fill radial-gradient:"hsl(0,255,60)"-"hsl(0,255,120)" circle 500,500,500,750

I tried more combinations and nothing:

fill radial-gradient:hsl(333,0,231)-hsl(333,0,226) circle 1000,1000,647,1353

fill "radial-gradient:hsl(333,0,231)-hsl(333,0,226)" circle 1000,1000,647,1353

fill "radial-gradient:hsl(333,0,231)"-"hsl(333,0,226) circle 1000,1000,647,1353
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: radial-gradient issue in mvg files

Post by snibgo »

rocastro wrote:-draw @draw_circle.mvg
The contents of the file draw_circle.mvg needs to be valid syntax for the "-draw" command.
snibgo's IM pages: im.snibgo.com
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

If the mvg file is:

fill "hsl(0,255,60)" circle 500,500,500,750

Then no problem.

It's no posible to use fill radial-gradient in mvg files?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: radial-gradient issue in mvg files

Post by snibgo »

You can put anything you want in any file you want.

But if you want to use the file in ...

Code: Select all

-draw @file.ext
... then it needs to be valid syntax for the "-draw" command.
snibgo's IM pages: im.snibgo.com
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

Please , can you help me with this problem , I'm new to the mvg language and this is not very well documented
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: radial-gradient issue in mvg files

Post by snibgo »

Please don't multi-post. It just confuses people.

For MVG documentation, see http://www.imagemagick.org/script/magic ... aphics.php

But within a "-draw @file.ext" file, you don't use MVG. You use draw syntax. See http://www.imagemagick.org/script/comma ... s.php#draw
snibgo's IM pages: im.snibgo.com
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

Sorry for the multi-post.

Thank's I have this information but I can't paint a gradient from a mvg file. I'm tring the linear gradient from the link whith MVG Gradients:

http://www.linux-nantes.org/~fmonnier/OCaml/MVG/

But it doesn't work. At the first line say:

'."\n"; ?>

And convert.exe say error: non-conforming drawing primitive definition '."\n"; ?>

if I remove this line it doesn't work. I'm tried changing the quotes and nothing

If I remove the first line, then convert paint stripes not a gradient.

This is the mvg file:

push graphic-context
viewbox 0 0 260 180
affine 1 0 0 1 0 0
push defs
push gradient "linearGradient_A" linear 0.4,0 0.6,1
stop-color "#ee1122" 0
stop-color "#ddaa44" 0.6
stop-color "#4488ff" 1
pop gradient
pop defs
push graphic-context
fill "url(#linearGradient_A)"
rectangle 0,0 260,180
pop graphic-context
pop graphic-context
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

Searching older posts I found this:

viewtopic.php?t=17031

http://www.imagemagick.org/Usage/draw/#svg

I tried the mvg file of the example on this link and it works Ok whith linear gradient:

Code: Select all

push graphic-context
viewbox 0 0 1000 1000
affine 1 0 0 1 0.0 0.0
push defs
push gradient 'gradient' linear 0,0 1000,1000
stop-color 'rgb(255,255,0)' 0%
stop-color 'rgb(255,0,0)' 100%
pop gradient
pop defs
push graphic-context
fill 'url(#gradient)'
rectangle 0,0 1000,1000
pop graphic-context
pop graphic-context
But if the gradient is radial it doesn't work:

Code: Select all

push graphic-context
viewbox 0 0 1000 1000
affine 1 0 0 1 0.0 0.0
push defs
push gradient 'gradient' radial 500,500 500,500, 250
stop-color 'rgb(255,255,0)' 0%
stop-color 'rgb(255,0,0)' 100%
pop gradient
pop defs
push graphic-context
fill 'url(#gradient)'
rectangle 0,0 1000,1000
pop graphic-context
pop graphic-context
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

The svg version of radial gradient works Ok.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1"
   x="0" y="0"
   width="1000" height="1000"
   xml:space="preserve">

  <defs id="def_A">
    <radialGradient id="Gradient_B"
                    gradientUnits="userSpaceOnUse"
                    cx="500" cy="500" r="250" fx="500" fy="500">
      <stop offset="0" stop-color="rgb(255,255,0)" />
      <stop offset="1"   stop-color="rgb(255,0,0)" />
    </radialGradient>
  </defs>

  <circle id="circle_A"
     cx="500"  cy="500"
     r="250"  
     style="fill:url(#Gradient_B);" />

</svg>
But the converted version to mvg doesn't work

Code: Select all

push graphic-context
encoding "UTF-8"
viewbox 0 0 1000 1000
affine 1 0 0 1 0 0
push defs
push gradient 'Gradient_B' radial 500,500 500,500 250
gradient-units 'userSpaceOnUse'
stop-color 'rgb(255,255,0)' 0
stop-color 'rgb(255,0,0)' 1
pop gradient
pop defs
push graphic-context
fill 'url(#Gradient_B)'
circle 500,500 500,750
pop graphic-context
pop graphic-context
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: radial-gradient issue in mvg files

Post by snibgo »

This sounds like a bug. A developer would need to comment.
snibgo's IM pages: im.snibgo.com
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

Ok, thanks.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: radial-gradient issue in mvg files

Post by dlemstra »

It took a while but we figured out what was going on. There was no support for a radial gradient. It would always be a linear gradient but you would not notice that because of the second set of coordinates. You should do this instead:

Code: Select all

push gradient 'Gradient_B' radial 500,500 0,0 250
But then you will notice it looks odd and that is because the wrong coordinates are being used when the gradient is drawn inside the circle. We fixed both issues and this will be available in the beta of 6.9.1-9 some time tomorrow.

We also added support for more than two stop colors in ImageMagick 7. We won't be adding this to ImageMagick 6 for now but that won't be a problem in your situation.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
rocastro
Posts: 10
Joined: 2015-07-07T08:21:36-07:00
Authentication code: 1151

Re: radial-gradient issue in mvg files

Post by rocastro »

Okay, thanks for your time and review the problem. Imagemagick is a great program for image treatment through commands.
Post Reply