DanBloomberg / leptonica

Leptonica is an open source library containing software that is broadly useful for image processing and image analysis applications. The official github repository for Leptonica is: danbloomberg/leptonica. See leptonica.org for more documentation.
Other
1.76k stars 387 forks source link

Can't write 32 bit depth image with color map to JPEG #604

Closed nam-leduc closed 1 year ago

nam-leduc commented 2 years ago

Hi maintainer, I see the issue when I use the leptonica at the latest version. The issue is: "Can't write 32 bit depth image with color map to JPEG"

Because I can't provide the input image, so, I would like to proof by reviewing code. I debugged into Leptonica and see that it seem the bug. You can check the following place, the function pixWriteStreamJpeg said that all bit depth is ok But the following line use function pixRemoveColormap

https://github.com/DanBloomberg/leptonica/blob/d4ab740f6c0d40fe12ddc15c9ceba1f614711665/src/jpegio.c#L835-L839

The function pixRemoveColormap just accept {1,2,4,8} bpp

https://github.com/DanBloomberg/leptonica/blob/d4ab740f6c0d40fe12ddc15c9ceba1f614711665/src/pixconv.c#L354-L357

And the result is the function pixWriteStreamJpeg don't write the image to file.

DanBloomberg commented 2 years ago

The only valid colormap images in leptonica are 1, 2, 4 and 8 bpp. For example, an 8 bpp colormap image can have up to 2^8 (i.e., 256) colors.

DanBloomberg commented 2 years ago

Planning to close this issue. Any further thoughts?