Closed loorke closed 5 months ago
This has been asked before in older issues. https://github.com/gographics/imagick/issues/219#issuecomment-564338281
Does that fix it?
@justinfx, mw.SetOption("webp:lossless", "false")
doesn't seem to make any difference. The size of the resulting image stays the same as the original while convert webp:lossless=false
gives a tenfold reduction.
SetOption
expects the flag to be the first arg and the value as the second, ie this example:
https://github.com/gographics/imagick/blob/c0ff8ece52769dbb8bc2ad4855d33226e50db92b/examples/bunny/main.go#L55
Can you try this?
mw.SetOption("define", "webp:lossless=false")
I've tried
mw.SetOption("define", "webp:lossless=false")
mw.SetOption("webp:lossless", "false")
mw.SetOption("lossless", "false")
mw.SetOption("-define", "webp:lossless=false")
None of these worked :((
This doc implies that there should be 3 arguments (not counting the MagickWand reference).
Though in this example the MagickSetOption()
with 2 arguments is being used. The ambiguity of MagickWand API is beyond my comprehension.
This should be the correct signature, with the 2 args. Otherwise the API would not compile: https://imagemagick.org/api/magick-property.php#MagickSetOption
Can you please include an example of how you are using the option? It could be an order-of-operations issue, where you are setting the option AFTER you have created the images. It is supposed to be set BEFORE you create images.
You're right, my bad. I was setting the option after the writing. Although mw.SetOption("define", "webp:lossless=false")
was still not working, turns out one should do mw.SetOption("webp:lossless", "false")
after all. Thank you very much!
That is fascinating. You are right that it is hard to understand the ImageMagick docs. It requires a lot of googling and looking at answers to questions. Technically from the way it is documented, it shouldn't work the way you mentioned. But we only wrap the call to MagickSetOption
and pass it the 2 arguments. So it is kind of up to the C API as to what is expects. It isnt clear to me why it automatically assumes those options are equivalent to -define
. Unless -define
itself is really just a helper for passing arbitrary non-first-class flags to delegate plugins. ie there is no -webp:lossless
flag.
In the ImageMagick documentation on WebP encoding options there is a following example:
I couldn't find neither define nor lossless methods in both imagick Go package and magickwand C API documentation. Does anyone have any idea on how to set webp specific properties?