HOME

TheInfoList



OR:

libjpeg is a free
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
with functions for handling the
JPEG 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 im ...
image data format. It implements a JPEG
codec A codec is a device or computer program that encodes or decodes a data stream or signal. ''Codec'' is a portmanteau of coder/decoder. In electronic communications, an endec is a device that acts as both an encoder and a decoder on a signal or ...
(encoding and decoding) alongside various utilities for handling JPEG data. It is written in C and distributed as
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, ...
together with its
source code In computing, source code, or simply code, is any collection of code, with or without comment (computer programming), comments, written using a human-readable programming language, usually as plain text. The source code of a Computer program, p ...
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. JPEG
JFIF 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 J ...
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.


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

The
command-line A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
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: * optimisation of the Huffman coding layer of a JPEG file to increase compression, * conversion between progressive and sequential JPEG formats, * conversion between Huffman and arithmetic coding in the entropy coding layer. These transformations are each completely lossless and reversible. The transformations on the image data comprise: * eliminate non-standard application-specific data inserted by some image programs, * perform certain transformations on a file, such as: ** discarding of colour channels (conversion to greyscale), ** rotating and flipping in steps of 90 degrees, ** cropping or joining at image block borders (every 8×8 or 16×16 pixels), ** rescaling. These are
lossless Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits statistic ...
and reversible only regarding the image data that is kept. Reencoding with repeated lossy quantisation of the image data (
generation loss Generation loss is the loss of quality between subsequent copies or transcodes of data. Anything that reduces the quality of the representation when copying, and would cause further reduction in quality on making a copy of the copy, can be cons ...
) does not take place. There is an associated Windows application
Jpegcrop
which provides a user interface to ''jpegtran''. For Unix-like systems like
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
there is the fre
CropGUI
with similar functionality. More programs supporting JPEG lossless transformation functions based on the IJG code are given on th


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 Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
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. 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. 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. After 11 years and a change in leadership, the IJG released new versions of libjpeg (7 through 9), of which each broke ABI compatibility with previous versions. The changes that were held in prospect after the 6x series were not delivered. In version 7, support for arithmetic coding was introduced, which earlier has been rejected because of the
patent A patent is a type of intellectual property that gives its owner the legal right to exclude others from making, using, or selling an invention for a limited period of time in exchange for publishing an sufficiency of disclosure, enabling disclo ...
situation, as well as the crop feature in jpegtran (-crop). Versions 8 and 9 served basically for the introduction of controversial incompatible format extensions. These are widely regarded as ineffective and inferior to existing, standardised solutions. Their standardisation was rejected after submission to the
ITU-T The ITU Telecommunication Standardization Sector (ITU-T) is one of the three sectors (divisions or units) of the International Telecommunication Union (ITU). It is responsible for coordinating standards for telecommunications and Information Commu ...
. The original organiser Tom Lane and others criticize these changes as a break from the goals of the IJG. 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 Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
script ''jpegcrush'' from x264's main developer Loren Merritt and integrated it into the code base of libjpeg-turbo. 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 Facebook is an online social media and social networking service owned by American company Meta Platforms. Founded in 2004 by Mark Zuckerberg with fellow Harvard College students and roommates Eduardo Saverin, Andrew McCollum, Dustin ...
, Inc. donated for the development of the next version, and
CloudFlare Cloudflare, Inc. is an American content delivery network and DDoS mitigation company, founded in 2009. It primarily acts as a reverse proxy between a website's visitor and the Cloudflare customer's hosting provider. Its headquarters are in San ...
assigned a developer for the improvement of mozjpeg.


Versions


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.


libjpeg-turbo

libjpeg-turbo is a fork of libjpeg that uses
SIMD Single instruction, multiple data (SIMD) is a type of parallel processing in Flynn's taxonomy. SIMD can be internal (part of the hardware design) and it can be directly accessible through an instruction set architecture (ISA), but it should ...
instructions to accelerate baseline JPEG encoding and decoding. Many projects are now using libjpeg-turbo instead of libjpeg, including popular Linux distributions (
Fedora A fedora () is a hat with a soft brim and indented crown.Kilgour, Ruth Edwards (1958). ''A Pageant of Hats Ancient and Modern''. R. M. McBride Company. It is typically creased lengthwise down the crown and "pinched" near the front on both sides ...
,
Debian Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of De ...
, Mageia, openSUSE, ...),
Mozilla Mozilla (stylized as moz://a) is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, spreads and supports Mozilla products, thereby promoting exclusively free software and open standards, w ...
, and
Chrome Chrome may refer to: Materials * Chrome plating, a process of surfacing with chromium * Chrome alum, a chemical used in mordanting and photographic film Computing * Google Chrome, a web browser developed by Google ** ChromeOS, a Google Chrome- ...
. 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. libjpeg v7, v8 and v9 broke ABI compatibility with prior releases. libjpeg-turbo can be configured to be compatible with the libjpeg v7 or v8 ABI, but it does not implement the complete set of features in recent IJG releases, including the SmartScale format extension. The libjpeg-turbo Project has chosen not to support SmartScale, citing concerns regarding the fact that it is not an
ITU-T The ITU Telecommunication Standardization Sector (ITU-T) is one of the three sectors (divisions or units) of the International Telecommunication Union (ITU). It is responsible for coordinating standards for telecommunications and Information Commu ...
standard and citing their own research that questions the usefulness of the feature. 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. Therefore, SmartScale files created by libjpeg v8 and later will not be decompressed correctly by libjpeg-turbo. libjpeg-turbo is one of the two JPEG reference implementations, available a
ISO/IEC 10918-7
an
ITU-T T.873
The other reference implementation is ISO libjpeg which also includes support for JPEG XT and JPEG LS.


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 Trellis quantization is an algorithm that can improve data compression in Discrete cosine transform, DCT-based encoding methods. It is used to optimize residual Discrete cosine transform, DCT coefficients after Motion compensation#Motion estimatio ...
. Additionally, the presets are aggressively tuned towards the minimisation of file sizes. Besides libjpeg-turbo, mozjpeg also builds upon jpegcrush, a
Perl Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
script by Loren Merritt.


ISO libjpeg

ISO/IEC Joint Photography Experts Group maintains a reference software implementation for base
JPEG 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 im ...
(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). 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

* Lossless editing * The Guetzli JPEG encoder


References


External links

*
JPEGclub
– Additional features for libjpeg
JPEG FAQs

libjpeg-turbo
an ABI-/API-compatible fork of libjpeg that uses x86 SIMD instructions to achieve a substantial speedup over the reference implementation. * * {{cite web , first1= Robert , last1= Nyman , first2= Josh , last2= Aas , date= Aug 6, 2014 , url= https://hacks.mozilla.org/2014/08/using-mozjpeg-to-create-efficient-jpegs/ , title= Using mozjpeg to Create Efficient JPEGs , publisher= Mozilla , work= Hacks JPEG Graphics libraries C (programming language) libraries Free software programmed in C