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

API method to set image filter #5825

Closed
ansstuff opened this issue Nov 28, 2022 · 5 comments
Closed

API method to set image filter #5825

ansstuff opened this issue Nov 28, 2022 · 5 comments

Comments

@ansstuff
Copy link

Is your feature request related to a problem? Please describe.

Some ImageMagick docs recommend using "Distort Resize" instead of simple "Resize" for higher quality slower resizing.
With MagickWand API it means using MagickDistortImage() instead of MagickResizeImage(). But MagickDistortImage() doesn't have a way to define which filter is used for resampling, it just uses currently configured filter, and there's no API methods to change the filter.

With commandline IM it's possible:
magick.exe input.png -filter Lanczos -distort Resize 200x200! output.png

So for now I have to run CLI process each time, with obvious drawbacks (disk IO, lost precision on conversions).

Describe the solution you'd like

As suggested in this discussion (Wand is IM binding for Python) a clean solution would be introducing new API methods to get/set filter:

FilterType MagickGetImageFilter(MagickWand *wand);
MagickBooleanType MagickSetImageFilter(MagickWand *wand, FilterType filter);

Describe alternatives you've considered

Alternatively, MagickDistortImage() could use an additional argument const FilterType filter, similar to MagickResizeImage(), the argument may be useful for some other DistortMethods as well, not just 'resize'.

Additional context

No response

@urban-warrior
Copy link
Member

urban-warrior commented Nov 29, 2022

Try MagickSetOption(wand,"filter","Lanczos"); to set the image filter to Lanczos before you read your image. Let us know if that works for you. In the mean time, we'll add the API methods you recommended.

@ansstuff
Copy link
Author

Try MagickSetOption(wand,"filter","Lanczos"); to set the image filter to Lanczos before you read your image. Let us know if that works for you.

It doesn't work, the "filter" option seems to be ignored.
Only MagickCore SetImageOption and then SyncImageSettings works, but Python binding of IM needs MagickWand API.
Thank you!

urban-warrior pushed a commit that referenced this issue Nov 30, 2022
@urban-warrior
Copy link
Member

We added support for image filters in MagickWand as you suggested.

@ansstuff
Copy link
Author

Thanks! Maybe this should be reflected in docs, as all existing IM bindings can benefit from the addition.

@urban-warrior
Copy link
Member

Done.

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

2 participants