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

1bit greyscale encoder support #24

Open
mostley opened this issue Jan 11, 2022 · 4 comments
Open

1bit greyscale encoder support #24

mostley opened this issue Jan 11, 2022 · 4 comments

Comments

@mostley
Copy link

mostley commented Jan 11, 2022

Any plans on supporting bit depths other than 8 and 16? I would have use for a 1bit greyscale implementation. Also not averse to contributing but would like some hints why other depths weren't implemented before I spent time and dig in to avoid double work.

Great library btw. I'm really impressed with the speed, it even beat the ImageDecoder from the browser built-in WebCodecs for small greyscale pngs.

@targos
Copy link
Member

targos commented Jan 12, 2022

Hello, would you be able to share a problematic image with us? There is nothing that specifically forbids 1bit images (https://github.com/image-js/fast-png/blob/master/src/PngDecoder.ts#L475-L486), but it is not tested because we have never encountered such images.

@mostley
Copy link
Author

mostley commented Jan 12, 2022

oh sorry, I wasn't precise enough. I meant 1bit greyscale support for the encoder:

throw new Error('unreachable');

We are using fast-png to create, store and read bitmasks for that images with 1bit depth would be much smaller than greyscale images. I'll see if I can create one with another encoder.

@targos
Copy link
Member

targos commented Jan 12, 2022

I see. Feel free to try and implement it here if you want!

@mostley
Copy link
Author

mostley commented Jan 12, 2022

ok, so I gather there's no reason it wasn't done before just that there was no need up to now? Just making sure there's no reason like there's no good 1bit datastructure in javascript ;)

just for reference:
test_bitmask_1bit

@targos targos changed the title 1bit greyscale support 1bit greyscale encoder support Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants