Skip to content
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

Possible bug in -define for gradient #7143

Closed
fmw42 opened this issue Mar 4, 2024 · 16 comments
Closed

Possible bug in -define for gradient #7143

fmw42 opened this issue Mar 4, 2024 · 16 comments

Comments

@fmw42
Copy link

fmw42 commented Mar 4, 2024

ImageMagick version

7.1.1.29

Operating system

MacOS

Operating system, version and so on

Ventura

Description

I am not sure I understand the following define or perhaps there is a bug. It is not working as I might expect. But I could just not understand how it should work.

-define gradient:bounding-box=widthxheight+x+y

I tried:

magick -size 500x500 -define gradient:bounding-box=400x200+50+200 gradient:red-blue x.png

expecting to see a red-blue gradient inside the 500x500 size. But I got a completely red image

x

Is my syntax correct?

Steps to Reproduce

See above

Images

see above

@snibgo
Copy link

snibgo commented Mar 4, 2024

I confirm the weirdness.

If we use offsets that are less then the dimensions, we get a gradient. For example:

magick -size 500x500 -define gradient:bounding-box=400x200+150+150 gradient:red-blue x.png

x

With these parameters, I would expect the top-left of the gradient to be at (150,150), and the gradient would be 400x200 pixels.

The gradient does start at y=150, but nothing else is as expected.

@fmw42
Copy link
Author

fmw42 commented Mar 4, 2024

Besides the lack of x offset, it also does not look like the gradient goes to pure red at the top of the gradient. I would have thought the gradient would be a full gradient inside the bounding box. It looks like a crop of a 500x500 gradient rather than a full gradient in the bounding box. The documentation is not clear on this point.

@urban-warrior
Copy link
Member

Gradients theoretically follow the SVG standard. Write an SVG gradient and the magick command-line equivalent. If they do not match, ImageMagick may have a bug which we will investigate further.

@fmw42
Copy link
Author

fmw42 commented Mar 5, 2024

Here is my SVG file that I saved as grad.svg

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="500" height="500" viewBox="0 0 500 500" version="1.1"
     xmlns="http://www.w3.org/2000/svg">
  <g>
    <defs>
      <linearGradient id="MyGradient">
        <stop offset="0%" stop-color="red" />
        <stop offset="100%" stop-color="blue" />
      </linearGradient>
    </defs>

    <!-- The rectangle is filled using a linear gradient paint server -->
    <rect fill="url(#MyGradient)" stroke="none"   
          x="100" y="100" width="300" height="200"/>
  </g>
</svg>

grad.svg.zip

magick grad.svg grad_svg.png

grad_svg

Here is the IM command

magick -size 500x500 -define gradient:direction=east -define gradient:bounding-box=300x200+100+100 gradient:red-blue grad_im.png

grad_im

It is not respecting the X-offset nor the dimension of the bounding box

urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this issue Mar 9, 2024
@urban-warrior
Copy link
Member

Thank you for reporting the issue. We have successfully reproduced it and are actively working on a patch to resolve it. You can expect this patch to be merged into the main GIT branch, later today. As part of our commitment to quality, this fix will also be included in the upcoming beta releases of ImageMagick by tomorrow. Your patience and feedback are greatly appreciated.

@fmw42 fmw42 reopened this Apr 10, 2024
@fmw42
Copy link
Author

fmw42 commented Apr 10, 2024

I am still getting a totally red image. No blue gradient. IM 7.1.1.30 Mac OSX Ventura

magick -size 500x500 -define gradient:bounding-box=400x200+50+200 gradient:red-blue x.png

@fmw42
Copy link
Author

fmw42 commented Apr 22, 2024

FYI, still only a solid red output in 7.1.1-31 for

magick -size 500x500 -define gradient:bounding-box=400x200+50+200 gradient:red-blue x.png

@urban-warrior
Copy link
Member

Thank you for reporting the issue. We have successfully reproduced it and are actively working on a patch to resolve it. You can expect this patch to be merged into the main GIT branch, later today. As part of our commitment to quality, this fix will also be included in the upcoming beta releases of ImageMagick by tomorrow. Your patience and feedback are greatly appreciated.

@fmw42 fmw42 reopened this Apr 27, 2024
@fmw42
Copy link
Author

fmw42 commented Apr 27, 2024

This is still not working correctly at least as I expect in IM 7.1.1.31 Mac OSX Ventura

magick -size 500x500 -define gradient:bounding-box=400x200+150+150 gradient:red-blue x.png

x

The width is not 400 and height is not 200. It has a width of 250 and height of 50.

magick x.png -format "%@" info:
250x50+150+150

@urban-warrior
Copy link
Member

With version 7.1.1-31, we get

image

@fmw42
Copy link
Author

fmw42 commented Apr 27, 2024

I am on the same version and do not get that result!

@urban-warrior
Copy link
Member

We tried the command on several Linux boxes and Windows and we also tried with the latest IM version 6 release and they all produced the image above.

@fmw42
Copy link
Author

fmw42 commented Apr 27, 2024

I will try the beta to see if it is there for me.

@fmw42
Copy link
Author

fmw42 commented Apr 27, 2024

It works in IM 7.1.1.32 beta, but not in IM 7.1.1.31 Mac OSX. Are you sure that you are using a clean version of 7.1.1.31 and not a version based upon mods for the next release?

@urban-warrior
Copy link
Member

The simplest solution is to wait for the next release of ImageMagick, sometime this week.

@fmw42
Copy link
Author

fmw42 commented Apr 29, 2024

No problem. That was what I thought also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants