Libjpeg

Last updated
libjpeg
Developer(s) Independent JPEG Group
Guido Vollbeding (maintainer) [1] [2]
Initial releaseOctober 7, 1991;32 years ago (1991-10-07)
Stable release
9f [3]   OOjs UI icon edit-ltr-progressive.svg / 14 January 2024;8 months ago (14 January 2024)
Repository github.com/thorfdbg/libjpeg
Written in C
Operating system Cross-platform
Type library
License Custom BSD-like (free software)
Website ijg.org
jpegclub.org

libjpeg is a free library with functions for handling the JPEG image data format. It implements a JPEG codec (encoding and decoding) alongside various utilities for handling JPEG data. It is written in C and distributed as free software together with its source code under the terms of a custom permissive (BSD-like) free software license, which demands attribution. The original variant is maintained and published by the Independent JPEG Group (IJG). Meanwhile, there are several forks with additional features.

Contents

JPEG JFIF images are widely used on the Web. The amount of compression can be adjusted to achieve the desired trade-off between file size and visual quality. [4]

Utilities

The following utility programs are shipped together with libjpeg:

cjpeg and djpeg
for performing conversions between JPEG and some other popular image file formats.
rdjpgcom and wrjpgcom
for inserting and extracting textual comments in JPEG files.
jpegtran
for transformation of existing JPEG files.

jpegtran

jpegtran transforms JPEG data without reencoding
(here with user interface CropGUI) CropGUI GTK small.png
jpegtran transforms JPEG data without reencoding
(here with user interface CropGUI)

The command-line program jpegtran provides several features for reformatting and recoding the representation of the DCT coefficients, for transformation of actual image data and for discarding auxiliary data in JPEG files, respectively. The transformations regarding the representation of the coefficients comprise:

These transformations are each completely lossless and reversible. The transformations on the image data comprise:

These are lossless and reversible only regarding the image data that is kept. Reencoding with repeated lossy quantisation of the image data (generation loss) does not take place.

History

The JPEG implementation of the Independent JPEG Group (IJG) was first publicly released on 7 October 1991 and has been considerably developed since that time. The development was initially mainly done by Tom Lane. The open-source implementation of the IJG was one of the major open-source packages and was key to the success of the JPEG standard. Many companies incorporated it into a variety of products such as image editors and web browsers. [9]

For version 5, which was released on September 24, 1994, the whole code base was rewritten. It introduced the utility programs rdjpgcom and wrjpgcom for handling embedded text comments. The version 6 from 2 August 1995 came with support for progressive JPEG and for the first time with the utility program jpegtran. This utility was extended with features to rotate and flip images and grayscale reduction in version 6b.

libjpeg-turbo and descendants

From version 6b of libjpeg of 27 March 1998, Miyasaka Masaru forked a branch named libjpeg/SIMD, which included x86 SIMD optimisations. It got substantial contributions from the TigerVNC and the VirtualGL projects in 2009. On that basis the libjpeg-turbo project was created in 2010. [10]

On 4 March 2014, the first version of the filesize-optimising fork MozJPEG was published. For this version Josh Aas from Mozilla Research reworked the Perl script jpegcrush from x264's main developer Loren Merritt and integrated it into the code base of libjpeg-turbo. [11]

On 10 July 2014, Mozilla released version 2.0, which mainly added trellis quantisation and is now able to reduce the size of baseline JPEGs also. Facebook, Inc. donated 60000 dollars for the development of the next version, [12] and CloudFlare assigned a developer for the improvement of MozJPEG. [13]

In 2019, libjpeg-turbo became the ISO and ITU endorsed reference implementation for the JPEG format. [14]

In April 2024, Google introduced Jpegli, a new JPEG coding library that offers enhanced capabilities and a 35% compression ratio improvement at high quality compression settings, while the coding speed is comparable with MozJPEG. [15]

Change in IJG leadership

After 11 years and a change in leadership, the IJG under Guido Vollbeding released new versions of libjpeg (7 through 9), of which each broke ABI compatibility with previous versions. [16] The changes that were held in prospect after the 6x series were not delivered. [17] In version 7, support for arithmetic coding was introduced, which earlier has been rejected because of the patent situation, as well as the crop feature in jpegtran (-crop). [17]

Versions 8 and 9 served basically for the introduction of controversial [18] incompatible format extensions. These are widely regarded as ineffective and inferior to existing, standardised solutions. [19] [20] Their standardisation was rejected after submission to the ITU-T. The original organiser Tom Lane and others criticize these changes as a break from the goals of the IJG. [18]

Versions

VersionReleasedNew features
ITU T.81 JPEG Compatible
Old version, no longer maintained: 11991
  • First release
  • Baseline or optimized JPEG
  • GIF or PPM output
Old version, no longer maintained: 21991
  • Internal improvements
  • More input/output formats
Old version, no longer maintained: 31992Internal and image quality improvements
Old version, no longer maintained: 41992Internal and speed improvements
Old version, no longer maintained: 4a1993-02-18
Old version, no longer maintained: 51994-09-24Internal improvements and revised API
Old version, no longer maintained: 5a1994-12-07
Old version, no longer maintained: 5b1995-03-15
Old version, no longer maintained: 61995-08-02
  • Progressive JPEG
  • jpegtran (convert between baseline and progressive)
Old version, no longer maintained: 6a1996-02-07
Old version, yet still maintained: 6b1998-03-27
  • jpegtran extended to lossless rotate

(used by libjpeg-turbo, MozJPEG and Jpegli)

Old version, no longer maintained: 72009-06-27
  • jpegtran extended to lossless crop
  • T.851 Arithmetic Coding [21]
  • Scaled DCT [22]
Proprietary non-compatible extensions
Old version, no longer maintained: 82010-01-10
  • SmartScale extension (ITU rejected) [23] [24]
  • jpegtran extended to use SmartScale
  • Internal fixes
Old version, no longer maintained: 8a2010-02-28RGBA
Old version, no longer maintained: 8b2010-05-16Memory corruption & build fixes
Old version, no longer maintained: 8c2011-01-16Option for selecting DCT block size (SmartScale)
Old version, no longer maintained: 8d2012-01-15RGB JPEG (no color transform to YCbCr)
Old version, no longer maintained: 92013-01-13
  • YCoCg color
  • Lossless compression (1x1 DCT) [25]
Old version, no longer maintained: 9a2014-01-19
  • "JFIFv2" scRGB Wide color gamut (standard unknown)
  • 8-12 bit color (standardJPEG)
Old version, no longer maintained: 9b2016-01-17Computation improvements
Old version, no longer maintained: 9c2018-01-14jpegtran -wipe
Old version, no longer maintained: 9d2020-01-12
  • Code cleanup
  • Huffman optimization
  • x64 support (MSVC)
  • jpegtran -drop
Old version, no longer maintained: 9e2022-01-16ARM and ARM64 support (MSVC)
Current stable version:9f2024-01-14
  • ARM64EC support (MSVC)
  • Xcode build system
  • C++Builder/RAD Studio build system
Legend:Old version, not maintainedOld version, still maintainedCurrent stable versionLatest preview versionFuture release

Forks

Well-known forks are libjpeg-turbo, which optimises for speed of execution, and MozJPEG, which optimises for smaller file sizes.

There is also a similarly named library from the ISO, which aims to be a complete implementation of JPEG, JPEG XT and JPEG-LS standards. [26]

libjpeg-turbo

libjpeg-turbo
Developer(s) libjpeg-turbo Project
Initial releaseNovember 19, 2010;13 years ago (2010-11-19)
Stable release
3.0.4 [27]   OOjs UI icon edit-ltr-progressive.svg / 14 September 2024;3 days ago (14 September 2024)
Repository github.com/libjpeg-turbo
Website libjpeg-turbo.org

libjpeg-turbo is a fork of libjpeg that uses SIMD instructions to accelerate baseline JPEG encoding and decoding. Many projects are now using libjpeg-turbo instead of libjpeg, including popular Linux distributions (Fedora, Debian, Mageia, openSUSE, ...), Mozilla, and Chrome. [28] [29] [30] Apart from performance, some projects have chosen to use libjpeg-turbo because it allows them to retain backward ABI compatibility with the older libjpeg v6b release. [31] libjpeg v7, v8 and v9 broke ABI compatibility with prior releases. [16]

libjpeg-turbo implements the standard-compliant arithmetic coding and lossless crop features seen in libjpeg v7. It can also be configured to be compatible with the libjpeg v7 or v8 ABI, but it does implement DCT scaling and the proprietary SmartScale, which builds on DCT scaling. [32] libjpeg-turbo chooses not to support SmartScale, because it is not an ITU-T standard and because their own research finds it (and DCT scaling) ineffective. [22] By extension, since the only major new feature in libjpeg v9 is specific to the SmartScale format, the libjpeg-turbo Project has chosen to forgo emulating libjpeg v9. [19]

Since 2019, libjpeg-turbo is one of the two JPEG reference implementations, available as ISO/IEC 10918-7 and ITU-T T.873. [14] The other reference implementation is ISO libjpeg which also includes support for JPEG XT and JPEG LS.

MozJPEG

MozJPEG
Developer(s) Mozilla Research
Initial releaseMarch 4, 2014;10 years ago (2014-03-04)
Stable release
4.1.5 / October 12, 2023;11 months ago (2023-10-12) [33]
Website github.com/mozilla/mozjpeg

MozJPEG is a fork from libjpeg-turbo done by Josh Aas and others from Mozilla Research. It aims to speed up loading times of webpages by achieving a reduction in file size (of about 10%) and therefore transmission time through improvement of coding efficiency while retaining image quality. To achieve this, it uses more processing power for the encoding (asymmetry) while retaining full compatibility with the JPEG standard and requiring no changes on the decoder side.

The techniques MozJPEG uses to achieve high compression include optimising Huffman trees, using progressive coding to optimally split the spectrum of DCT coefficients into separate scans, and through the use of trellis quantisation. Additionally, the presets are aggressively tuned towards the minimisation of file sizes.

Besides libjpeg-turbo, MozJPEG also builds upon jpegcrush, a Perl script by Loren Merritt. [11] [34]

Jpegli

Jpegli
Developer(s) Google
Initial releaseNovember 14, 2020;3 years ago (2020-11-14)
Stable release
0.10.2 / March 8, 2024;6 months ago (2024-03-08)
Website github.com/google/jpegli

In April 2024, Google introduced Jpegli, a new JPEG coding library that offers enhanced capabilities and a 35% compression ratio improvement at high quality compression settings, while the coding speed is comparable with MozJPEG. [35]

ISO libjpeg

ISO/IEC Joint Photography Experts Group maintains a reference software implementation for base JPEG (ISO/IEC 10918-1 and 18477-1) and JPEG XT extensions (ISO/IEC 18477 Parts 2 and 6-9), as well as lossless JPEG-LS (ISO/IEC 14495). [36] It also includes some of the optimizations of MozJPEG. Though also named libjpeg, it is not related to the source code provided by Independent JPEG Group (IJG) and does not support proprietary extensions introduced by IJG since 2007.

See also

Related Research Articles

In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compression reduces bits by identifying and eliminating statistical redundancy. No information is lost in lossless compression. Lossy compression reduces bits by removing unnecessary or less important information. Typically, a device that performs data compression is referred to as an encoder, and one that performs the reversal of the process (decompression) as a decoder.

<span class="mw-page-title-main">JPEG</span> Lossy compression method for reducing the size of digital images

JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality. Since its introduction in 1992, JPEG has been the most widely used image compression standard in the world, and the most widely used digital image format, with several billion JPEG images produced every day as of 2015.

<span class="mw-page-title-main">Lossy compression</span> Data compression approach that reduces data size while discarding or changing some of it

In information technology, lossy compression or irreversible compression is the class of data compression methods that uses inexact approximations and partial data discarding to represent the content. These techniques are used to reduce data size for storing, handling, and transmitting content. The different versions of the photo of the cat on this page show how higher degrees of approximation create coarser images as more details are removed. This is opposed to lossless data compression which does not degrade the data. The amount of data reduction possible using lossy compression is much higher than using lossless techniques.

<span class="mw-page-title-main">Image compression</span> Reduction of image size to save storage and transmission costs

Image compression is a type of data compression applied to digital images, to reduce their cost for storage or transmission. Algorithms may take advantage of visual perception and the statistical properties of image data to provide superior results compared with generic data compression methods which are used for other digital data.

<span class="mw-page-title-main">JPEG 2000</span> Image compression standard and coding system

JPEG 2000 (JP2) is an image compression standard and coding system. It was developed from 1997 to 2000 by a Joint Photographic Experts Group committee chaired by Touradj Ebrahimi, with the intention of superseding their original JPEG standard, which is based on a discrete cosine transform (DCT), with a newly designed, wavelet-based method. The standardized filename extension is .jp2 for ISO/IEC 15444-1 conforming files and .jpx for the extended part-2 specifications, published as ISO/IEC 15444-2. The registered MIME types are defined in RFC 3745. For ISO/IEC 15444-1 it is image/jp2.

The JPEG File Interchange Format (JFIF) is an image file format standard published as ITU-T Recommendation T.871 and ISO/IEC 10918-5. It defines supplementary specifications for the container format that contains the image data encoded with the JPEG algorithm. The base specifications for a JPEG container format are defined in Annex B of the JPEG standard, known as JPEG Interchange Format (JIF). JFIF builds over JIF to solve some of JIF's limitations, including unnecessary complexity, component sample registration, resolution, aspect ratio, and color space. Because JFIF is not the original JPG standard, one might expect another MIME type. However, it is still registered as "image/jpeg".

<span class="mw-page-title-main">Advanced Video Coding</span> Most widely used standard for video compression

Advanced Video Coding (AVC), also referred to as H.264 or MPEG-4 Part 10, is a video compression standard based on block-oriented, motion-compensated coding. It is by far the most commonly used format for the recording, compression, and distribution of video content, used by 91% of video industry developers as of September 2019. It supports a maximum resolution of 8K UHD.

JBIG is an early lossless image compression standard from the Joint Bi-level Image Experts Group, standardized as ISO/IEC standard 11544 and as ITU-T recommendation T.82 in March 1993. It is widely implemented in fax machines. Now that the newer bi-level image compression standard JBIG2 has been released, JBIG is also known as JBIG1. JBIG was designed for compression of binary images, particularly for faxes, but can also be used on other images. In most situations JBIG offers between a 20% and 50% increase in compression efficiency over Fax Group 4 compression, and in some situations, it offers a 30-fold improvement.

JBIG2 is an image compression standard for bi-level images, developed by the Joint Bi-level Image Experts Group. It is suitable for both lossless and lossy compression. According to a press release from the Group, in its lossless mode JBIG2 typically generates files 3–5 times smaller than Fax Group 4 and 2–4 times smaller than JBIG, the previous bi-level compression standard released by the Group. JBIG2 was published in 2000 as the international standard ITU T.88, and in 2001 as ISO/IEC 14492.

Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 2000, JPEG-LS, and JPEG XL.

JPEG XR is an image compression standard for continuous tone photographic images, based on the HD Photo specifications that Microsoft originally developed and patented. It supports both lossy and lossless compression, and is the preferred image format for Ecma-388 Open XML Paper Specification documents.

The Video Coding Experts Group or Visual Coding Experts Group is a working group of the ITU Telecommunication Standardization Sector (ITU-T) concerned with standards for compression coding of video, images, audio signals, biomedical waveforms, and other signals. It is responsible for standardization of the "H.26x" line of video coding standards, the "T.8xx" line of image coding standards, and related technologies.

JPEG is a format for compressed digital images.

A video coding format is a content representation format of digital video content, such as in a data file or bitstream. It typically uses a standardized video compression algorithm, most commonly based on discrete cosine transform (DCT) coding and motion compensation. A specific software, firmware, or hardware implementation capable of compression or decompression in a specific video coding format is called a video codec.

Motion JPEG 2000 is a file format for motion sequences of JPEG 2000 images and associated audio, based on the MP4 and QuickTime format. Filename extensions for Motion JPEG 2000 video files are .mj2 and .mjp2, as defined in RFC 3745.

High Efficiency Image File Format (HEIF) is a container format for storing individual digital images and image sequences. The standard covers multimedia files that can also include other media streams, such as timed text, audio and video.

JPEG XT is an image compression standard which specifies backward-compatible extensions of the base JPEG standard.

JPEG XL is a royalty-free raster-graphics file format that supports both lossy and lossless compression. It is designed to outperform existing raster formats and thus become their universal replacement.

JPEG XS is an interoperable, visually lossless, low-latency and lightweight image and video coding system used in professional applications. Applications of the standard include streaming high-quality content for virtual reality, drones, autonomous vehicles using cameras, gaming, and broadcasting. It was the first ISO codec ever designed for this specific purpose. JPEG XS, built on core technology from both intoPIX and Fraunhofer IIS, is formally standardized as ISO/IEC 21122 by the Joint Photographic Experts Group with the first edition published in 2019. Although not official, the XS acronym was chosen to highlight the eXtra Small and eXtra Speed characteristics of the codec. Today, the JPEG committee is still actively working on further improvements to XS, with the second edition scheduled for publication and initial efforts being launched towards a third edition.

References

  1. Göhler, Lars (April 29, 2020). "New Version of libjpeg (Ver. 9d) of Independent JPEG Group available now". JPEGclub.org. Independent JPEG Group. Retrieved 2021-01-25.
  2. Friesenhahn, Bob (June 6, 2020). "Re: [Libjpeg-devel-6x] 4 Integer Overflow Errors in libjpeg-9c". SourceForge.net. SourceForge . Retrieved 2021-01-25. The only concern was that Guido Vollbeding is not likely subscribed to this list and IJG JPEG is essentially developed by one person.
  3. "Independent JPEG Group" . Retrieved 27 January 2024.
  4. JPEG JFIF
  5. Jpegcrop Preferences and Options description
  6. Filmic Games >> The greatest failure of our patent system was... Archived 2012-09-01 at the Wayback Machine
  7. 680385 - Firefox does not show arithmetic coded jpegs
  8. New jpegtran features
  9. JPEG homepage
  10. "libjpeg-turbo". libjpeg-turbo.
  11. 1 2 André Kramer (heise.de-Newsticker), January 14, 2013: Mozilla-Encoder verbessert JPEG-Kompression
  12. Sebastian Grüner, 16. Juli 2014: MozJPEG 2.0: Facebook unterstützt JPEG-Encoder von Mozilla
  13. "CloudFlare möchte zu Mozillas JPEG-Encoder beitragen". 30 July 2014.
  14. 1 2 "ISO/IEC 10918-7:2019 Information technology — Digital compression and coding of continuous-tone still images — Part 7: Reference software". ISO. "T.873 (05/19): Information technology - Digital compression and coding of continuous-tone still images: Reference software". www.itu.int.
  15. "Introducing Jpegli: A New JPEG Coding Library". Google Open Source Blog. 3 April 2024. Archived from the original on 3 April 2024. Retrieved 4 April 2024.
  16. 1 2 "libjpeg: API/ABI changes review" . Retrieved 2017-10-28.
  17. 1 2 Mans Rullgard (Hardwarebug.org), August 4, 2009: IJG is back Archived 2014-07-16 at the Wayback Machine
  18. 1 2 Tom Lane, January 16, 2013: jpeg-9, API/ABI compatibility, and the future role of this project
  19. 1 2 "What About libjpeg v9?". libjpeg-turbo team. Retrieved February 8, 2013.
  20. Mans Rullgard (Hardwarebug.org), February 1, 2010: IJG swings again, and misses
  21. "ITU-T T.81 (JPEG-1)-based still-image coding using an alternative arithmetic coder" (pdf). September 2009.
  22. 1 2 "libjpeg-turbo | About / A Study on the Usefulness of DCT Scaling and SmartScale". libjpeg-turbo.org.
  23. ITU-T JPEG-Plus Proposal R3
  24. Evolution of JPEG
  25. JPEG 9 Lossless Coding
  26. "Libjpeg". GitHub . 6 October 2021.
  27. "Release 3.0.4 · libjpeg-turbo/libjpeg-turbo" . Retrieved 15 September 2024.
  28. Software That Uses or Provides libjpeg-turbo. February 9, 2012.
  29. Issue 48789 – chromium – Use libjpeg-turbo instead of libjpeg. April 14, 2011.
  30. Bug 698519 – Update to libjpeg-turbo 1.2. February 28, 2012
  31. libjpeg for F14. February 9, 2012.
  32. libjpeg-turbo README file Archived 2018-12-14 at the Wayback Machine
  33. "Releases · mozilla/mozjpeg". github.com. Retrieved 2022-08-14.
  34. Andreas Donath (golem.de), March 6, 2014: Mozilla will JPEGs besser komprimieren
  35. "Introducing Jpegli: A New JPEG Coding Library". Google Open Source Blog. 3 April 2024. Archived from the original on 3 April 2024. Retrieved 4 April 2024.
  36. "Jpeg - Jpeg Xt".