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

Sparse color barycentric example #7

Closed
pgajdos opened this issue Jan 15, 2025 · 12 comments
Closed

Sparse color barycentric example #7

pgajdos opened this issue Jan 15, 2025 · 12 comments

Comments

@pgajdos
Copy link

pgajdos commented Jan 15, 2025

magick -size 100x100 xc:none -draw "polygon 30,10  10,80  90,90" \
          -colorspace RGB \
          -sparse-color Barycentric '30,10 red   10,80 blue   90,90 lime' \
          -colorspace sRGB   sparse_bary_triangle_2.png

does not produce colorful triangle on white background:

https://usage.imagemagick.org/canvas/sparse_bary_triangle_2.png

but colorful canvas:

sparse_bary_triangle_2

I tried several versions of ImageMagick, e. g. 7.1.1-43 or 7.0.7-34 with same result. I tried also 6.8.8.1 and expected triangle was produced indeed.

@dlemstra
Copy link
Member

Why did you open the issue here? What are you seeing where?

@pgajdos
Copy link
Author

pgajdos commented Jan 15, 2025

Why did you open the issue here?

Should I open the issue in some other category? 'Barycentric' example in https://usage.imagemagick.org/canvas/ does not work as I would expect reading the example doc.

What are you seeing where?

Not sure I understand.

@dlemstra
Copy link
Member

This is the repository for the Freds-Scripts and not our Usage website. I will move this.

@dlemstra dlemstra transferred this issue from ImageMagick/Freds-Scripts Jan 15, 2025
@pgajdos
Copy link
Author

pgajdos commented Jan 15, 2025

I see, thanks.

@fmw42
Copy link

fmw42 commented Jan 15, 2025

You are using the wrong example from https://usage.imagemagick.org/canvas/#barycentric

Try

magick -size 100x100 xc: -colorspace RGB \
          -sparse-color Barycentric '30,10 red   10,80 blue   90,90 lime' \
          -colorspace sRGB  -fill white -stroke black \
          \( -size 100x100 xc:black -draw 'polygon 30,10  10,80  90,90' \) \
          -alpha off -compose CopyOpacity -composite \
          -draw 'circle 30,10 30,12  circle 10,80 10,82  circle 90,90 90,92' \
          sparse_bary_triangle.png

Which produces a colorful triangle on transparent background.

sparse_bary_triangle

You were using the code for the example above this that makes a full colorful image.

@pgajdos
Copy link
Author

pgajdos commented Jan 15, 2025

Thanks, Fred, that is true.

However my concern is, that the creation of sparse_bary_triangle_2.png in the doc does not produce the documented result as I understand, is that correct?

@fmw42
Copy link

fmw42 commented Jan 15, 2025

Which example are you really using? Both examples produce the correct image as shown on his page if you remove the examples from the page and view them in a viewer that supports transparency (for the second image).

The first example produces the full colorful image as he shows.

The second example produces a triangle on transparent background. It looks white because it is displayed on the page on a white background (which shows through the transparency).

Please clarify which example you are complaining about and what image you get?

@pgajdos
Copy link
Author

pgajdos commented Jan 15, 2025

I am sorry, I do not probably understand and do not know how to rephrase my initial comment. I basically run the command from there (taken from https://usage.imagemagick.org/canvas/) to create sparse_bary_triangle_2.png, as the doc says. Instead of https://usage.imagemagick.org/canvas/sparse_bary_triangle_2.png I get the image in my initial comment.

@pgajdos
Copy link
Author

pgajdos commented Jan 15, 2025

I am sorry for these four issues we have found. Anyway, thanks to all (Fred, Anthony, Dirk, Christy, ...) for this great documentation.

@fmw42
Copy link

fmw42 commented Jan 15, 2025

Sorry, my mistake. I do get your result, which does not match the posted example. I will look into it, but I suspect something changed since that was posted.

@fmw42
Copy link

fmw42 commented Jan 15, 2025

The example works in IM 6 (as when created). But due to changes for IM 7, it needs a slight modification due to how the alpha channel is processed.

IM 6

convert -size 100x100 xc:none -draw "polygon 30,10  10,80  90,90" \
          -colorspace RGB \
          -sparse-color Barycentric '30,10 red   10,80 blue   90,90 lime' \
          -colorspace sRGB   sparse_bary_triangle_2.png

IM 7

magick -size 100x100 xc:none -draw "polygon 30,10  10,80  90,90" \
          -colorspace RGB -channel rgb \
          -sparse-color Barycentric '30,10 red   10,80 blue   90,90 lime' \
          -colorspace sRGB   sparse_bary_triangle_2.png

Both generate:

sparse_bary_triangle_2

@pgajdos
Copy link
Author

pgajdos commented Jan 16, 2025

Fred, awesome, -channel rgb did it.

Thank you!

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

4 participants