GithubHelp home page GithubHelp logo

munchpass / gifsicle-go Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 5.78 MB

Go wrapper around gifsicle with bundled binaries for quick and easy GIF compression

License: MIT License

Go 100.00%
gif gif-compression gif-compressor gifsicle go gifsicle-bin gifsicle-go

gifsicle-go's Introduction

gifsicle-go

A Go wrapper around gifsicle with bundled binaries for quick and easy GIF compression with just a single go get!

gifsicle is one of the most popular GIF compression tools used by many online GIF compression websites like ezgif.com.

Table of Contents

Install

We bundle the binaries through embeds, so all you need is a go get:

go get github.com/munchpass/gifsicle-go

No need to have gifsicle pre-installed!

Usage

Compress

If you just want to quickly compress a GIF and write the result into a buffer:

	var buf bytes.Buffer
	err = gifsicle.Compress(&buf, decodedGif, &gifsicle.Options{
		Lossy:         80,
		OptimizeLevel: gifsicle.OPTIMIZE_LEVEL_THREE,
	})
	if err != nil {
		return err
	}

Gifsicle

This library also provides the Gifsicle struct which is a thin wrapper around the gifsicle CLI tool.

Here are some examples:

Compress an input GIF file and write the result to an output GIF file:

	sourceGif := path.Join("testfiles", "portrait_3mb.gif")
	outputGif := path.Join("testoutput", "portrait_3mb_output.gif")
	err = g.InputFile(sourceGif).
		OutputFile(outputGif).
		Lossy(80).
		OptimizeLevel(gifsicle.OPTIMIZE_LEVEL_THREE).
		Run()

Compress an input GIF object and write the result to an output GIF file:

	err = g.InputGif(sourceGif).
		OutputFile(outputGif).
		Lossy(80).
		OptimizeLevel(gifsicle.OPTIMIZE_LEVEL_THREE).
		Run()

Compress an input GIF object and write the result to an output buffer:

    var buf bytes.Buffer
	err = g.InputGif(sourceGif).
		Output(&buf).
		Lossy(80).
		OptimizeLevel(gifsicle.OPTIMIZE_LEVEL_THREE).
		Run()

Contributing

This library is still in its early stage, but is actively used in production. We welcome any PRs/suggestions!

gifsicle-go's People

Contributors

jchen42703 avatar

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.