All Projects → stbrumme → toojpeg

stbrumme / toojpeg

Licence: Zlib license
A JPEG encoder in a single C++ file

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to toojpeg

Guetzling
Guetzling is a simple script for macOS and Linux written in Bash, to automate (recursively finding files) the compression of jpegs using the Guetzli algorithm.
Stars: ✭ 20 (-77.78%)
Mutual labels:  jpeg-encoder
Guetzli
Perceptual JPEG encoder
Stars: ✭ 12,600 (+13900%)
Mutual labels:  jpeg-encoder
Mozjpeg
Improved JPEG encoder.
Stars: ✭ 4,738 (+5164.44%)
Mutual labels:  jpeg-encoder
wasm-jpeg-ijg
Demo from Chrome Dev Summit of using Web Assembly to optimize images in a browser
Stars: ✭ 54 (-40%)
Mutual labels:  jpeg-encoder
simple-guetzli
Batch Guetzli compressions in a manageable fashion
Stars: ✭ 14 (-84.44%)
Mutual labels:  jpeg-encoder
pyguetzli
Python bindings for Google's Guetzli, a JPEG encoder that optimises JPEG compression
Stars: ✭ 28 (-68.89%)
Mutual labels:  jpeg-encoder

A JPEG encoder in a single C++ file

This is a mirror of my library hosted at https://create.stephan-brumme.com/toojpeg/

TooJpeg is a compact baseline JPEG/JFIF writer, written in C++11 (but looks like C for the most part).
Its interface has only one function: writeJpeg() - and that's it !

My library supports the most common JPEG output color spaces:

  • YCbCr444,
  • YCbCr420 (=2x2 downsampled) and
  • Y (grayscale)

Saving NASA's huge 21600x10800px blue marble image with quality=90 takes just 2.4 (YCbCr420) or 3.6 seconds (YCbCr444) on a standard x64 machine - faster than other small JPEG encoders.
The compiled library enlarges your binary by about 7kb (CLang x64) or 12kb (GCC x64) in -O3 mode.
Far more details can be found on the project homepage: https://create.stephan-brumme.com/toojpeg/

How to use

  1. create an image with any content you like, e.g. 1024x768, RGB (3 bytes per pixel)
   auto pixels = new unsigned char[1024*768*3];
  1. define a callback that receives the compressed data byte-by-byte
// for example, write to disk (could be anything else, too, such as network transfer, in-memory storage, etc.)
void myOutput(unsigned char oneByte) { fputc(oneByte, myFileHandle); }
  1. start JPEG compression
TooJpeg::writeJpeg(myOutput, mypixels, 1024, 768);
// actually there are some optional parameters, too
//bool ok = TooJpeg::writeJpeg(myOutput, pixels, width, height, isRGB, quality, downSample, comment);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].