The image/jpeg and image/png packages have Decode and Encode functions that read and write jpeg and png images, but the image/gif package does not - only Decode and DecodeAll.
Any ideas then, on how to encode a gif image.Image into an io.Writer?
The Go standard library doesn't include a GIF encoder.
I think your best bet will be to use cgo to interface with a C library which encodes GIFs. giflib looks reasonably straight forward.
Alternatively you could port the relevant parts of giflib to go and submit them to the standard library.
There is a historical reason why GIF encoding isn't widespread - it was covered by patents on the LZW compression used. However those patents have now expired so there is no reason not to have a compressor in the standard library other than the fact that GIFs aren't as popular as they used to be!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With