GithubHelp home page GithubHelp logo

aprimadi / imagecomp Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 2.0 4 KB

Golang Image Compression Tool

Go 100.00%
golang pngquant mozjpeg image-optimization image-compression google-pagespeed-insights google-pagespeed

imagecomp's Introduction

imagecomp

imagecomp is an image optimization or compression library written in Golang that uses pngquant and mozjpeg under the hood. It is useful for optimizing images to conform to the Google PageSpeed Insights suggestion (https://developers.google.com/speed/pagespeed/insights/)

Dependencies

imagecomp requires pngquant and mozjpeg to be installed.

On Mac OS X

To install the dependencies using brew do:

brew install pngquant
brew install mozjpeg

On Ubuntu

To install pngquant:

sudo apt-get install pngquant

To install mozjpeg:

git clone https://github.com/mozilla/mozjpeg.git
cd mozjpeg
autoreconf -fiv
./configure
make
sudo make install
sudo ln -s /opt/mozjpeg/bin/cjpeg /usr/bin/cjpeg
sudo ln -s /opt/mozjpeg/bin/jpegtran /usr/bin/jpegtran

Usage

To install, do:

go get github.com/aprimadi/imagecomp
go install github.com/aprimadi/imagecomp

To optimize images on a given directory do:

imagecomp .

Multiple directories can also be specified:

imagecomp app/assets public/assets

Advanced Options

imagecomp accepts two options -include and -exclude which supports wildcard character *. Use this two options to include and exclude path or images being optimized. All paths are included by default.

Example:

imagecomp . -exclude "public/assets/*"

Not the use of quote ", this is mandatory otherwise the command line (i.e. bash) will replace the arguments with real path.

Also, note that order matters. For example:

imagecomp . -exclude "*" -include "*.jpg"

Is not the same as:

imagecomp . -include "*.jpg" -exclude "*"

Which will excludes all images from being compressed, while the former only process .jpg images.

Author

Armin Primadi https://github.com/aprimadi

This library were developed by the engineering team at Dexcode.

imagecomp's People

Contributors

aprimadi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

imagecomp's Issues

broken dependencies

Hi,
I compiling this package, but ran into this error.

cannot find package "github.com/pierrec/lz4/v3" in any of:
/usr/local/Cellar/go/1.13.7/libexec/src/github.com/pierrec/lz4/v3 (from $GOROOT)
/Users/obad/go/src/github.com/pierrec/lz4/v3 (from $GOPATH)

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.