go-quantize icon indicating copy to clipboard operation
go-quantize copied to clipboard

Adds QuantizeMultiple, which produces a palette for a slice of images

Open carbocation opened this issue 5 years ago • 1 comments

As noted in #1 , for animated gifs, it is ideal to build a palette that is aware of all of the images that will contribute to the gif. This pull request adds QuantizeMultiple, which ingests a slice of images rather than a single image. This preserves Quantize in order to prevent breaking the public API. It modifies the private API by changing buildBucketMultiple to buildBucket and causing it to ingest a slice of images rather than just one.

Visually/subjectively, this produces nicer appearing images for me than (a) applying Quantize either to every image separately, which can lead to palette jitter between frames, or (b) applying Quantize to just one key image and applying the palette to every image, which can lead to inappropriate coloration in some frames.

carbocation avatar Jul 05 '20 22:07 carbocation

Thanks for the contribution, this definitely seems useful!

This is perhaps a little pedantic, but could we modify the internal buildBucketMultiple api to avoid having to allocate the additional parameter slice? Perhaps make the signature still accept a single image, but also an optional colorBucket so that multiple images can be made into one bucket? I doubt either case affects runtime substantially but keeping the magic allocs number down is somewhat of a personal goal for this project.

I can also try this change out sometime if you'd prefer not to bother with it.

ericpauley avatar Oct 12 '20 16:10 ericpauley