libvips / lua-vips

Lua binding for the libvips image processing library
MIT License
125 stars 10 forks source link

addalpha() support #47

Closed RiskoZoSlovenska closed 2 years ago

RiskoZoSlovenska commented 2 years ago

The VIPS docs mention an addalpha() function, but attempting to call image:addalpha() results in a VipsOperation: class "addalpha" not found error. I'm not sure why exactly this is. It's mentioned here that addalpha is just a convenience function for bandjoin_const, but I don't see what makes it different from any other operation that the binding supports.

I'd open a PR, but thing is, I'm not sure how to implement it. Typically, I'd just make a call to vips_lib.vips_addalpha(), but pyvips defines the function manually, so there might be something I'm missing.

jcupitt commented 2 years ago

Hi @RiskoZoSlovenska,

Most libvips operations are defined as subclasses of VipsOperation, and they all just appear in lua-vips automatically. A few very simple things (eg. addalpha, which is just two lines of code) are tiny convenience functions and are implemented in the bindings themselves.

I'd implement addalpha in lua in Image_methods.lua, which I guess is what you've done in your PR. I'll have a look.