Go - Encoding gif image.Image

The image / jpeg and image / png packages have decoding and encoding functions that read and write jpeg and png images, but the image / gif package not only decodes and decodes.

Any ideas, for example, on how to encode a gif image. Create an io.Writer file?

+7
source share
1 answer

The standard Go Go library does not include a GIF encoder.

I think your best bet is to use cgo to interact with the C library, which encodes GIFs. giflib looks reasonably straight.

Alternatively, you can transfer the corresponding parts of giflib and send them to the standard library.

There is a historical reason that GIF encoding is not widespread - it was covered by patents for the LZW compression used. However, these patents have now expired, so there is no reason not to have a compressor in the standard library, except that GIFs are not as popular as before!

+8
source

All Articles