Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality

Overview

Guetzli

Introduction

Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.

Build Status

Building

On POSIX systems

  1. Get a copy of the source code, either by cloning this repository, or by downloading an archive and unpacking it.
  2. Install libpng. If using your operating system package manager, install development versions of the packages if the distinction exists.
    • On Ubuntu, do apt-get install libpng-dev.
    • On Fedora, do dnf install libpng-devel.
    • On Arch Linux, do pacman -S libpng.
    • On Alpine Linux, do apk add libpng-dev.
  3. Run make and expect the binary to be created in bin/Release/guetzli.

On Windows

  1. Get a copy of the source code, either by cloning this repository, or by downloading an archive and unpacking it.
  2. Install Visual Studio 2015 and vcpkg
  3. Install libpng using vcpkg: .\vcpkg install libpng.
  4. Cause the installed packages to be available system-wide: .\vcpkg integrate install. If you prefer not to do this, refer to vcpkg's documentation.
  5. Open the Visual Studio project enclosed in the repository and build it.

On macOS

To install using Homebrew:

  1. Install Homebrew
  2. brew install guetzli

To install using the repository:

  1. Get a copy of the source code, either by cloning this repository, or by downloading an archive and unpacking it.
  2. Install Homebrew or MacPorts
  3. Install libpng
    • Using Homebrew: brew install libpng.
    • Using MacPorts: port install libpng (You may need to use sudo).
  4. Run the following command to build the binary in bin/Release/guetzli.
    • If you installed using Homebrew simply use make
    • If you installed using MacPorts use CFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' make

With Bazel

There's also a Bazel build configuration provided. If you have Bazel installed, you can also compile Guetzli by running bazel build -c opt //:guetzli.

Using

Note: Guetzli uses a large amount of memory. You should provide 300MB of memory per 1MPix of the input image.

Note: Guetzli uses a significant amount of CPU time. You should count on using about 1 minute of CPU per 1 MPix of input image.

Note: Guetzli assumes that input is in sRGB profile with a gamma of 2.2. Guetzli will ignore any color-profile metadata in the image.

To try out Guetzli you need to build or download the Guetzli binary. The binary reads a PNG or JPEG image and creates an optimized JPEG image:

guetzli [--quality Q] [--verbose] original.png output.jpg
guetzli [--quality Q] [--verbose] original.jpg output.jpg

Note that Guetzli is designed to work on high quality images. You should always prefer providing uncompressed input images (e.g. that haven't been already compressed with any JPEG encoders, including Guetzli). While it will work on other images too, results will be poorer. You can try compressing an enclosed sample high quality image.

You can pass a --quality Q parameter to set quality in units equivalent to libjpeg quality. You can also pass a --verbose flag to see a trace of encoding attempts made.

Please note that JPEG images do not support alpha channel (transparency). If the input is a PNG with an alpha channel, it will be overlaid on black background before encoding.

Comments
  • Building on OS X

    Building on OS X

    $ ~ brew list
    ... gflags libpng ... 
    $ ~/git/guetzli make
    ==== Building guetzli (release) ====
    guetzli.cc
    guetzli/guetzli.cc:24:10: fatal error: 'gflags/gflags.h' file not found
    #include "gflags/gflags.h"
             ^
    1 error generated.
    make[1]: *** [obj/Release/guetzli.o] Error 1
    make: *** [guetzli] Error 2 
    

    Anyone gotten this to work?

    opened by dalanmiller 14
  • Cannot run guetzli after build

    Cannot run guetzli after build

    I just got the latest guetzli release, and I have been trying to run it on my Ubuntu 17.04, I used the installation instructions from the README.md file, however, even after the successful build it keeps saying: guetzli: command not found Also there is no file created in bin/Release/ Please help.

    opened by 0x1za 9
  • Support reading from stdin and writing to stdout

    Support reading from stdin and writing to stdout

    Allows invocations like cat test.png | guetzli - - > test.jpg as requested in #104.

    Retains optimization to preallocate buffer, if seeking is possible. Always uses in-memory buffer for libpng ensuring input file is only read once.

    opened by fkistner 7
  • CentOS `make` Compile error

    CentOS `make` Compile error

    Installed dependency package libpng libpng-devel gflags gflags-devel.

    yum install -y libpng libpng-devel gflags gflags-devel

    make //The error is as follows

    ==== Building guetzli (release) ==== butteraugli_comparator.cc Package gflags was not found in the pkg-config search path. Perhaps you should add the directory containing `gflags.pc' to the PKG_CONFIG_PATH environment variable No package 'gflags' found cc1plus: error: unrecognized command line option "-std=c++11" make[1]: *** [obj/Release/butteraugli_comparator.o] Error 1 make: *** [guetzli] Error 2

    opened by bbcw 7
  • Homebrew gflags has no `libgflags.pc`

    Homebrew gflags has no `libgflags.pc`

    Building from master (c78689c5e020c0cd3580783213798b6323eaa454) on macOS gives me the following error:

    ==== Building guetzli (release) ====
    Creating obj/Release
    butteraugli_comparator.cc
    Package libgflags was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libgflags.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libgflags' found
    
    ...snip...
    
    butteraugli.cc
    Package libgflags was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libgflags.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libgflags' found
    Linking guetzli
    Package libgflags was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libgflags.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libgflags' found
    Undefined symbols for architecture x86_64:
      "google::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)", referenced from:
          __GLOBAL__sub_I_guetzli.cc in guetzli.o
      "google::FlagRegisterer::FlagRegisterer<double>(char const*, char const*, char const*, double*, double*)", referenced from:
          __GLOBAL__sub_I_guetzli.cc in guetzli.o
      "google::SetUsageMessage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
          _main in guetzli.o
      "google::ShowUsageWithFlags(char const*)", referenced from:
          _main in guetzli.o
      "google::ParseCommandLineFlags(int*, char***, bool)", referenced from:
          _main in guetzli.o
      "_png_create_info_struct", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_create_read_struct", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_destroy_read_struct", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_get_channels", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_get_image_height", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_get_image_width", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_get_rows", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_init_io", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_read_png", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
      "_png_set_longjmp_fn", referenced from:
          (anonymous namespace)::ReadPNG(__sFILE*, int*, int*, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >*) in guetzli.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [bin/Release/guetzli] Error 1
    make: *** [guetzli] Error 2
    

    As part of the Homebrew gflags package, the pkg-config file is gflags.pc, not libgflags.pc so the build process can't set up the build flags properly.

    opened by msbit 7
  • Man files missing

    Man files missing

    Hi,

    I created the rpm package for CentOS7:

    $ sudo yum install http://rpm.axivo.com/axivo-release-7-1.noarch.rpm
    $ sudo yum --enablerepo=axivo install guetzli
    $ yum -q info guetzli
    Installed Packages
    Name        : guetzli
    Arch        : x86_64
    Version     : 1.0
    Release     : 1.el7
    Size        : 473 k
    Repo        : installed
    From repo   : axivo
    Summary     : Perceptual JPEG encoder
    URL         : https://github.com/google/guetzli
    License     : ASL 2.0
    Description : Guetzli is a JPEG encoder that aims for excellent compression density at high
                : visual quality. Guetzli-generated images are typically 20-30% smaller than
                : images of equivalent quality generated by libjpeg. Guetzli generates only
                : sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.
    

    The man files are missing for guetzli and butteraugli, I was wondering if I missed something into make:

    $ rpm -ql guetzli
    /usr/bin/butteraugli
    /usr/bin/guetzli
    /usr/share/doc/guetzli-1.0
    /usr/share/doc/guetzli-1.0/LICENSE
    /usr/share/doc/guetzli-1.0/README.md
    

    Regards,

    Floren Munteanu

    enhancement 
    opened by fmunteanu 6
  • Cause the Homebrew build to use newer source

    Cause the Homebrew build to use newer source

    opened by tliesnham 6
  • Result by guetzli: 1.3mb image compressed to 692.7kb. With Microsoft Paint, 1.3mb image compressed to 792kb.

    Result by guetzli: 1.3mb image compressed to 692.7kb. With Microsoft Paint, 1.3mb image compressed to 792kb.

    Hi,

    I just tried this tool and its great. As in, does the job. But when I showed it to a friend of mine, he compressed the same image using Microsoft paint and got a similar result.

    So, I'm just wondering how this tool is different and better than the other tools available out there? Also, the time taken by Paint is much less than the time taken by Guetzli.

    Is there anyone else who share a similar opinion?

    opened by rdp-in 6
  • Undefined reference to pthread_rwlock_init

    Undefined reference to pthread_rwlock_init

    Hey guys,

    in my system (Ubuntu Ubuntu 16.04.2 LTS 4.4.0-66-generic), I've gotten "Undefined reference to pthread_rwlock_init" in my build.

    In the file guetzli.make I've had to add -lpthread to LINKCMD variable. I don't if it was necessary in your build (maybe not), but I thought it would be interesting if you could add it in your source files.

    Best regards,

    Rodrigo Gonçalves de Branco

    more-data-requested 
    opened by rodrigogbranco 6
  • Build for Raspberry PI

    Build for Raspberry PI

    I want to use the Guetzli binary on my raspberry PI cluster; but there is no compiled release for the ARM architecture available. Do you guys think it's possible to build Guetzli on ARM?

    opened by rogierlommers 5
  • encode a png and use in AndroidStudio have an error

    encode a png and use in AndroidStudio have an error

    Error:Execution failed for task ':app:merge Guanfang Debug Resources'. > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

    more-data-requested 
    opened by NoahZu 5
  • Can't open input file

    Can't open input file

    I could convert tons of image. But It suddenly stop working. It says

    2021-08-14 01:46:37: Can't open input file 2021-08-14 01:46:37: guetzli_windows_x86-64.exe --verbose --quality 90 --nomemlimit 'C:**.jpg' 'C:**_guetzli.jpg' 2021-08-14 01:46:37: Finished with 1

    How can I solve this? I need to use this program :(

    opened by arty35 2
  • Golden files test is broken due to missing archive

    Golden files test is broken due to missing archive

    The test corpus in the url is not there any more, thus the test cannot be run. https://github.com/google/guetzli/blob/214f2bb42abf5a577c079d00add5d6cc470620d3/tests/golden_test.sh#L14

    opened by grafail 0
  • Update Visual Studio project to VS 2019

    Update Visual Studio project to VS 2019

    Currently the Visual Studio Solution File (guetzli.sln) and the project files (guetzli.vcxproj and guetzli_static.vcxproj) are configured for Visual Studio 2015. It would be nice if those could be recompiled for Visual Studio 2019, which increases compatibility and performance.

    opened by EwoutH 1
Releases(v1.0.1)
Owner
Google
Google ❤️ Open Source
Google
An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Starting in the late 80's I wrote my own imaging codecs for the existing standards (CCITT G3/G4 was the first). I soon added GIF, JPEG and not long after that, the PNG specification was ratified. All of this code was "clean room" - written just from the specification. I used my imaging library in many projects and products over the years and recently decided that some of my codecs could get a new lease on life as open source, embedded-friendly libraries for microcontrollers.

Larry Bank 38 Dec 30, 2022
Python envelope for the popular C library libjpeg for handling JPEG files.

jpeglib Python envelope for the popular C library libjpeg for handling JPEG files. libjpeg offers full control over compression and decompression and

Martin Benes 8 Dec 21, 2022
A deblocking JPEG decoder

Knusperli The goal of Knusperli is to reduce blocking artifacts in decoded JPEG images, by interpreting quantized DCT coefficients in the image data a

Google 454 Dec 22, 2022
CGIF, A fast and lightweight GIF encoder that can create GIF animations and images

CGIF, a GIF encoder written in C A fast and lightweight GIF encoder that can create GIF animations and images. Summary of the main features: user-defi

Daniel Löbl 75 Dec 28, 2022
Demo of a fast PNG encoder.

Fast PNG Encoder This is a proof-of-concept fast PNG encoder that uses AVX2 and a special Huffman table to encode images faster. Speed on a single cor

Luca Versari 58 Dec 27, 2022
PNG encoder and decoder in C and C++.

PNG encoder and decoder in C and C++, without dependencies

Lode Vandevenne 1.7k Dec 25, 2022
This is a demonstration repository for The Pitt Challenge project about medical image compression.

Image Compression for Portable Medical Records This is a demonstration repository for The Pitt Challenge project about medical image compression. Back

null 3 Oct 24, 2021
The “Quite OK Image” format for fast, lossless image compression

The “Quite OK Image” format for fast, lossless image compression

Dominic Szablewski 6k Dec 30, 2022
Lossy fixed-rate GPU-friendly image compression\decompression.

NotOkImageFormat Lossy fixed-rate GPU-friendly image compression\decompression. Supported profiles 16:1:1 2.8125 bpp yuv 4:1:1 3.75 bpp

Boris Batkin 11 Dec 5, 2022
QOY - The "Quite OK YCbCr420A" format for fast, lossless image compression

QOY - The "Quite OK YCbCr420A" format for fast, lossless* image compression ( * colorspace conversion to/from RGBA is lossy, if used ) Single-file MIT

Chainfire 19 Oct 1, 2022
Fast streaming PNG<->QOI converter with some compression-improving extensions

QOIG Fast streaming PNG<->QOI converter with some compression-improving extensions. Can achieve 1%-10% better compression than QOI without sacrificing

David Rutter 3 Oct 3, 2022
Video++, a C++14 high performance video and image processing library.

Video++ Video++ is a video and image processing library taking advantage of the C++14 standard to ease the writing of fast video and image processing

Matthieu Garrigues 692 Dec 28, 2022
ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

null 366 Dec 30, 2022
HDRView is a simple research-oriented image viewer with an emphasis on examining and comparing high-dynamic range (HDR) images

HDRView is a simple research-oriented high-dynamic range image viewer with an emphasis on examining and comparing images, and including minimalistic tonemapping capabilities. HDRView currently supports reading EXR, PNG, TGA, BMP, HDR, JPG, GIF, PNM, PFM, and PSD images and writing EXR, HDR, PNG, TGA, PPM, PFM, and BMP images.

Wojciech Jarosz 177 Jan 5, 2023
MozJPEG improves JPEG compression efficiency achieving higher visual quality and smaller file sizes at the same time

Mozilla JPEG Encoder Project MozJPEG improves JPEG compression efficiency achieving higher visual quality and smaller file sizes at the same time. It

Mozilla 5k Jan 4, 2023
Analysing and implementation of lossless data compression techniques like Huffman encoding and LZW was conducted along with JPEG lossy compression technique based on discrete cosine transform (DCT) for Image compression.

PROJECT FILE COMPRESSION ALGORITHMS - Huffman compression LZW compression DCT Aim of the project - Implement above mentioned compression algorithms an

null 1 Dec 14, 2021
This progrom aims at providing high-quality healthcare system for everyone ragardless of their social status.

This progrom aims at providing high-quality healthcare system for everyone ragardless of their social status. It tackles long-existed problems such as incompetent staff, long queues and outdated equipment. I am sure that this program has a potential to transform a healthcare system in our country.

Azimjon Abduvohidov 1 Jul 28, 2022
conversion from absolute encoder and incremental encoder, control two robotis dynamixel motors, testing qserialport library in qt

Q_dxl This example is created for testing: Serial connection Testing two dynamixel motors (eg. MX-28AT) Doing the conversion from absolute encoder (of

ibov 1 Oct 30, 2021
DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to create, design, and edit database files compatible with SQLite.

DB Browser for SQLite What it is DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to create, design, and edit database files c

null 17.5k Jan 2, 2023
D2R mod generator. Provide quick tool to generate .txt files to change game balance: increase drop, monster density or even randomize items.

Diablo 2 mod generator Generator is inspired by d2modmaker. It provides fast and easy way to create mod without any modding knowledge. Features includ

Smirnov Vladimir 31 Dec 22, 2022