Code Monkey home page Code Monkey logo

Comments (6)

disintegration avatar disintegration commented on June 22, 2024 2

@ernsheong The support for GIF format in Save function mentioned here was added in 2014 (c317ebd)

from imaging.

disintegration avatar disintegration commented on June 22, 2024

Hi,
Thank you!

What kind of gif support do you need? You can use imaging.Open to load a gif image. But you cannot use imaging.Save to save to gif file. The reason for this is that the GIF encoding was introduced in standard library with Go 1.2. And I want to keep the library compatible with older Go versions.

If you use Go version >= 1.2 you can use the standard image/gif package to save to gif format. For example (not tested):

import (
    "image/gif"
    "os"
)

func SaveGIF(img image.Image, filename string) (err error) {
    file, err := os.Create(filename)
    if err != nil {
        return
    }
    defer file.Close()
    err = gif.Encode(file, img, &gif.Options{NumColors: 256})
    return
}

from imaging.

 avatar commented on June 22, 2024

Your example code is very helpful.
Thank you so much for your awesome support. :)

from imaging.

pkieltyka avatar pkieltyka commented on June 22, 2024

just wondering.. but whats the point of trying to be compatible to Go versions < 1.2 .. ?

from imaging.

disintegration avatar disintegration commented on June 22, 2024

To not break other people's code that depends on this library. Saving GIFs can be implemented with just a few lines of code if needed.

from imaging.

ernsheong avatar ernsheong commented on June 22, 2024

Is this argument still valid? It is 2019.

from imaging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.