An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Overview

JPEGENC

Copyright (c) 2021 BitBank Software, Inc.
Written by Larry Bank
[email protected]

What is it?

An 'embedded-friendly' (aka Arduino) JPEG image encoding library

Why did you write it?

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.

What's special about it?

There are many open source libraries written for Linux that would be useful to run on embedded processors. What stops them from "just working" is that they depend on a file system, heap management and sometimes additional external dependencies. The purpose of this project is to provide a fast and convenient JPEG encoder which can run without an operating system or even a C-Runtime library. I've optimized the code for speed and memory usage so it should be faster than any other FOSS libraries available.

Feature summary:
----------------

  • Runs on any MCU with at least 4K of free RAM
  • No external dependencies (including malloc/free)
  • Encode an image MCU by MCU
  • Encode directly to your own buffer or a file with I/O callbacks you provide
  • Supported pixel types: grayscale, RGB565, RGB888 and ARGB8888 (alpha ignored)
  • Allows for optional color subsampling (4:4:4 or 4:2:0)
  • Supports 4 quality levels (LOW, MED, HIGH, BEST)
  • Arduino-style C++ library class with simple API
  • Can by built as straight C as well

How fast is it?
---------------
The examples folder contains a sketch to measure the performance of encoding a 1024x1024 image generated dynamically.

Documentation:
---------------
Detailed information about the API is in the Wiki
See the examples folder for easy starting points

You might also like...
A fast image processing library with low memory needs.

libvips : an image processing library Introduction libvips is a demand-driven, horizontally threaded image processing library. Compared to similar lib

C++ image processing and machine learning library with using of SIMD: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX-512, VMX(Altivec) and VSX(Power7), NEON for ARM.

Introduction The Simd Library is a free open source image processing and machine learning library, designed for C and C++ programmers. It provides man

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

a generic C++ library for image analysis

VIGRA Computer Vision Library Copyright 1998-2013 by Ullrich Koethe This file is part of the VIGRA computer vision library. You may use,

Intel® Open Image Denoise library
Intel® Open Image Denoise library

Intel Open Image Denoise is an open source library of high-performance, high-quality denoising filters for images rendered with ray tracing

libvot - A C++11 multi-thread library for image retrieval

libvot is a fast implementation of vocabulary tree, which is an algorithm widely used in image retrieval and computer vision. It usually comprises three components to build a image retrieval system using vocabulary tree: build a k-means tree using sift descriptors from images, register images into the database, query images against the database. I

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.

The CImg Library is a small and open-source C++ toolkit for image processing
The CImg Library is a small and open-source C++ toolkit for image processing

http://cimg.eu The CImg Library is a small and open-source C++ toolkit for image processing, designed with these properties in mind: CImg defines clas

Small header-only C library to decompress any BC compressed image

Small header-only C library to decompress any BC compressed image

Comments
  • question about very low quality endcoding

    question about very low quality endcoding

    Hi, Very nice project. I wonder if it could support very low quality 4:2:0 jpeg encoding. I'm going to compress 320x200 rgb frame, to size below 3kB. I know that's crazy :) It's because I'm author of free available system to control unamed RC planes, called Qczek LRS. and i'm going to add experimental support for slow video transmission over a LoRa link. It would be something like 1-2fps 320x200 but it would be cool to make it possible using limited and very small and cheap hardware... Just going to connect SPI capable cammera, encode it's tream and send ... What do you think? Kris

    You can find out more at the project site https://qczek.beyondrc.com/qczek-lrs-433mhz-1w-lora-rc-link/ Thank you in advance Kris

    opened by krzysztofkuczek 2
  • Converting a PNG image to JPEG

    Converting a PNG image to JPEG

    Is there a way to pipe the output from PNGdec to this library?
    I'm looking for a way to covert a PNG image on an SD card to JPEG and your libraries seem to be the right tools to use. I'd appreciate it if you could point me to the right direction, thanks.

    opened by alexqzd 2
  • Improve JPEGFixQuantE performances

    Improve JPEGFixQuantE performances

    Into JPEGFixQuantE(), the memcpy() is redundant. Actually, the sTemp[] array can be used directly in later calculation without affecting the results into pJPEG->sQuantTable[].

    opened by carlo-bramini 1
  • Issue when trying to decode after encode array from Portenta H7 camera.

    Issue when trying to decode after encode array from Portenta H7 camera.

    Hey! First of all, thanks for the code.

    I have been trying to encode and decode JPEG using this library on the Portenta H7:

    • GrayScale image from a camera is stored in 76800 bytes (320 * 240 * 1) array.
    • Image is compressed...
    int compress() {
      rc = jpg.open(ucTemp, sizeof(ucTemp));
    
      if (rc != JPEG_SUCCESS) {
        return -1;
      }
    
      rc = jpg.encodeBegin(&jpe, WIDTH, HEIGHT, JPEG_PIXEL_GRAYSCALE, JPEG_SUBSAMPLE_444, JPEG_Q_BEST);
      if (rc != JPEG_SUCCESS) {
        Serial.print("Failed with the code: " );
        Serial.println(rc);
        return -1;
      }
      
      iMCUCount = ((WIDTH + jpe.cx-1)/ jpe.cx) * ((HEIGHT + jpe.cy-1) / jpe.cy);
      for (int i = 0; i < iMCUCount; i++) {
        rc = jpg.addMCU(&jpe, fb_in.getBuffer(), WIDTH);
        if (rc != JPEG_SUCCESS) {
          Serial.print("Failed with the code: " );
          Serial.println(rc);
          return -1;     
        }
      }
      iDataSize = jpg.close();
      return iDataSize;
    }
    

    Where fb_inis the object holding the 76k800 bytes of the camera image. The WIDTH is set to 320 and the HEIGHT to 240.

    The compression returns no error, but then I send the data over the serial port to a python console and when I try to decode the JPEG and show the image, I get this:

    https://imgur.com/a/qid6YCi


    Here is a bit of the pythons code:

    from PIL import Image
    from io import BytesIO
    
    (... some serial port stuff .. )
    
    sizeOfTheImage = serialPort.readline()
    receivedBytes = serialPort.read(int(sizeOfTheImage))
    
    image = Image.open(BytesIO(receivedBytes))
    image.show()
    
    opened by nguterresn 1
Releases(1.0.0)
  • 1.0.0(Aug 12, 2021)

    This is code that I optimized many years ago for low-end PCs, but finds new life on modern microcontrollers. A simple API, yet covers most things that people need to accomplish with JPEG encoding. Requires 3-4K of RAM and should run well on any 32 or 64-bit CPU.

    Source code(tar.gz)
    Source code(zip)
Owner
Larry Bank
Call me Mr. Optimization. I optimize other people's code for a living.
Larry Bank
Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG.

TinyEXIF: Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG Introduction TinyEXIF is a tiny, lightweight C++ library for parsing the metada

cDc 84 Dec 18, 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
Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality

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.

Google 12.8k Jan 7, 2023
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
PoC black/white image sequence to dumpy gif image sequence converter

PoC black/white image sequence to dumpy gif image sequence converter

null 69 Dec 9, 2022
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
Arduino PNG image decoder library

An 'embedded-friendly' (aka Arduino) PNG image decoding library

Larry Bank 102 Jan 6, 2023
Rate-Distortion Optimized Lossy PNG Encoding Tool

rdopng is a command line tool which uses LZ match optimization, Lagrangian multiplier rate distortion optimization (RDO), a simple perceptual error tolerance model, and Oklab-based colorspace error metrics to encode 24/32bpp PNG files which are 30-80% smaller relative to lodepng/libpng.

Rich Geldreich 40 Dec 24, 2022
This library provides a cross-platform image loading library in C11 for projects based on our foundation library

Image Library - Public Domain This library provides a cross-platform image loading library in C11 for projects based on our foundation library.

Mattias Jansson 1 Jan 29, 2022