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

Document encoder quality setting more explicitly (WAS: quality 10 damages color) #6

Open
tomlarkworthy opened this issue Aug 30, 2015 · 9 comments

Comments

@tomlarkworthy
Copy link

I have a red square on a green background. With quality 10 the red square is draw black. With quality 1, it is fine. I assumed quality 10 was the highest, although the readme is somewhat vague on what that parameter does.

@janajri
Copy link

janajri commented Sep 15, 2015

@tomlarkworthy, I also thought 1 meant worse quality but taking a look at the code you'll see otherwise: https://github.com/eugeneware/gifencoder/blob/master/lib/GIFEncoder.js#L226

@sustained
Copy link

Just ran into this issue myself, what a strange choice to make 1 the "highest"!

@heikkipora
Copy link
Collaborator

Value range for setQuality is actually 1 - 30. This is directly defined by the color quantization algorithms.

setQuality() code comment says:

Sets quality of color quantization (conversion of images to the maximum 256
colors allowed by the GIF specification). Lower values (minimum = 1)
produce better colors, but slow processing significantly. 10 is the
default, and produces good color mapping at reasonable speeds. Values
greater than 20 do not yield significant improvements in speed.

NeueQuant constructor code comment says:

samplefac - sampling factor 1 to 30 where lower is better quality

TODO: Document at README level

@heikkipora heikkipora changed the title quality 10 damages color Document encoder quality setting more explicitly (WAS: quality 10 damages color) Jul 26, 2017
@dmitryshelomanov
Copy link

@heikkipora is it possible to hand the encoder multiple base64 image and transform to gif ? (without canvas, only base64 array)

@heikkipora
Copy link
Collaborator

heikkipora commented Dec 21, 2017

@userbq201: Unfortunately, no. Quote from the README.md: "The chunks that get emitted by your read stream must either by a 1-dimensional bitmap of RGBA data (either an array or Buffer), or a canvas 2D context."
This means you have to decode your base64 encoding and then decode whatever format your images are in - and pass the data as raw RGBA data to the GIF encoder.
The GIF encoder doesn't support any decoding (anyway, it's an encoder.. :-) )

@dmitryshelomanov
Copy link

@heikkipora jpg in array will suit ?

@heikkipora
Copy link
Collaborator

heikkipora commented Dec 21, 2017

@userbq201 your JPGs needs to be decoded to raw pixels (32bit rgba) before passing to the encoder

@JohnForster
Copy link

It would be nice if this info was in the readme

@danielo515
Copy link

I also vote for documenting this. Other derived libraries that use this one doesn't include the meaning either, so it is a chain of confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants