Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIF support #12

Closed
ghost opened this issue Aug 20, 2014 · 6 comments
Closed

GIF support #12

ghost opened this issue Aug 20, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 20, 2014

Dear Grigory Dryapak,

This is completely awesome open source code project, But it does't support GIF file.

Can you please provide GIF support for this.

Thank you.

@disintegration
Copy link
Owner

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
}

@ghost
Copy link
Author

ghost commented Aug 22, 2014

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

@pkieltyka
Copy link

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

@disintegration
Copy link
Owner

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.

@ernsheong
Copy link

Is this argument still valid? It is 2019.

@disintegration
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants