dpdhf02040
2019-01-12 05:49
浏览 419
已采纳

如何使用golang压缩和调整gif大小

Is there has method or lib to compress and resize a gif use golang?

ps: I was tried bimg, but it not support gif.

图片转代码服务由CSDN问答提供 功能建议

是否有使用golang压缩和调整gif大小的方法或lib? < p> ps:我尝试过 bimg ,但它不支持gif。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drt96856 2019-01-16 04:52
    已采纳

    see doc https://golang.org/pkg/image/gif/#GIF

    func DecodeAll(r io.Reader) (*GIF, error)
    

    now you can get a GIT struct

    type GIF struct {
            Image []*image.Paletted // The successive images.
    

    then you can resize each of Image in GIF.

    for _,img:=range gif.Image{
        resize(img)
    }
    

    PS: image.Paletted implemented image.Image. so you can use https://github.com/nfnt/resize to do your job.

    点赞 打赏 评论
  • dongqishun6409 2019-01-16 04:15

    I've never used but I think you can read/write GIFs using the std library (import "image/gif"). Then resize using something like "resize" (see Go Resizing Images)

    点赞 打赏 评论

相关推荐 更多相似问题