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 imag ...
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, n ...
together with its
source code In computing, source code, or simply code, is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the ...
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 In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods eit ...
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 JP ...
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 commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
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 In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding or using such a code proceeds by means of Huffman coding, an algo ...
layer of a JPEG file to increase compression, * conversion between progressive and sequential JPEG formats, * conversion between Huffman and
arithmetic coding Arithmetic coding (AC) is a form of entropy encoding used in lossless data compression. Normally, a string of characters is represented using a fixed number of bits per character, as in the ASCII code. When a string is converted to arithmetic ...
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 Flipping is a term used to describe purchasing a revenue-generating asset and quickly reselling (or "flipping") it for profit. Within the real estate industry, the term is used by investors to describe the process of buying, rehabbing, and sel ...
in steps of 90 degrees, ** cropping or joining at image block borders (every 8×8 or 16×16 pixels), ** rescaling. These are lossless 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 consid ...
) 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, whi ...
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 so ...
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 Arithmetic coding (AC) is a form of entropy encoding used in lossless data compression. Normally, a string of characters is represented using a fixed number of bits per character, as in the ASCII code. When a string is converted to arithmetic ...
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 enabling disclosure of the invention."A ...
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 Co ...
. 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, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
script ''jpegcrush'' from
x264 x264 is a free and open-source software library and a command-line utility developed by VideoLAN for encoding video streams into the H.264/MPEG-4 AVC video coding format. It is released under the terms of the GNU General Public License. Hi ...
'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, Dust ...
, 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 Sa ...
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 JPEG XT (ISO/IEC 18477) is an image compression standard which specifies backward-compatible extensions of the base JPEG standard (ISO/IEC 10918-1 and ITU Rec. T.81). JPEG XT extends JPEG with support for higher integer bit depths, high dynami ...
and JPEG-LS standards.


libjpeg-turbo

libjpeg-turbo is a
fork In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tine (structural), tines with which one ...
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 shoul ...
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 side ...
,
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 Mageia is a Linux-based operating system, distributed as free and open source software. It was forked from the Mandriva Linux distribution. The Greek term () means enchantment, fascination, glamour, wizardry. The first release of the soft ...
,
openSUSE openSUSE () is a free and open source RPM-based Linux distribution developed by the openSUSE project. The initial release of the community project was a beta version of SUSE Linux 10.0. Additionally the project creates a variety of tools, s ...
, ...),
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, ...
, and 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 Co ...
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. 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, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
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 imag ...
(ISO/IEC 10918-1 and 18477-1) and
JPEG XT JPEG XT (ISO/IEC 18477) is an image compression standard which specifies backward-compatible extensions of the base JPEG standard (ISO/IEC 10918-1 and ITU Rec. T.81). JPEG XT extends JPEG with support for higher integer bit depths, high dynami ...
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