slyrus / opticl

An image processing library for Common Lisp
Other
182 stars 35 forks source link

Cannot convert an image from greyscale+alpha #35

Open mfiano opened 4 years ago

mfiano commented 4 years ago

This case form needs a greyscale+alpha case:

https://github.com/slyrus/opticl/blob/e8684416eca2e78e82a7b436d436ef2ea24c019d/coerce.lisp#L206

mfiano commented 3 years ago

@slyrus I think this was fixed by you correct? But before it's closed, I just realized you cannot do the inverse: convert an RGBA image to grayscale+alpha though. I just had to hack in some ugly code to handle this. There should be a way to do what (coerce-image image '8-bit-grayscale-image) does, except a method specialized on 8-bit-grayscale-alpha-image that copies in the alpha channel from the source image.

slyrus commented 2 years ago

Hmm... Ok, in theory I have this now. One problem is that the writing routines (tiff, jpg, etc...) don't seem to support grayscale-alpha yet (but that's a separate problem). The other issue is what to make the default alpha value if we're coercing from something that doesn't have an alpha channel?

mfiano commented 2 years ago

I would signal a condition if it's not possible. I mostly only work with PNG, but for a portable image format library, I don't think you can do anything but signal and have the user handle the condition to their needs.

slyrus commented 2 years ago

Hmm... yes, that's probably a good idea. I added support for tiff, and jpeg just silently ignores the alpha channel - as it does for RGB. Could probably be improved.