JPEG (.jpg, .jpeg)
- Import and Export fully support the JPEG standard.
- Import and Export support Exif 2.3, IPTC 4.2, and XMP metadata standards.
Background & Context

-
- MIME type: image/jpeg
- JPEG raster image and compression format.
- Commonly used for photographic images by digital cameras and on the web.
- JPEG is an acronym for Joint Photographic Experts Group.
- Supports Grayscale, RGB, and CMYK color spaces.
- Stores images as bitmaps at a resolution of 8 bits per color channel.
- Binary format.
- Uses a lossy compression method based on an 8×8 block-sized discrete cosine transform.
- Supports different compression levels.
Import & Export

- Import["file.jpg"] imports a JPEG file, returning an image.
- Import["file.jpg",elem] imports the specified element from a JPEG file.
- The import format can be specified with Import["file","JPEG"] or Import["file",{"JPEG",elem,…}].
- Export["file.jpg",expr] exports an image, graphics, or any other expression as an image to a JPEG file.
- Image objects are by default exported at their full raster size. Graphics and other arbitrary expressions are exported using the same raster size as their displayed form.
- See the reference pages for full general information on Import and Export.
- ImportString and ExportString support the JPEG format.
Notebook Interface

- In the notebook front end, Insert ▶ Picture and the Open menu allow the import of a JPEG file into a cell.
- Save Selection As exports the selected part of a notebook as a JPEG file.
Import Elements



- General Import elements:
-
"Elements" list of elements and options available in this file "Rules" full list of rules for each element and option "Options" list of rules for options, properties, and settings - Data representation elements:
-
"ColorMap" color reduction palette "Data" array of pixel values "Graphics" raster image, given as a Graphics object "Image" raster image, given as an Image object "RawData" array of color map indices {"Thumbnail",size} thumbnail of the first image (default size = Small) - Import and Export by default use the "Image" element for the JPEG format.
- Advanced Import elements:
-
"BitDepth" bits used to represent each color channel in the file "CameraTopOrientation" orientation of the camera when the picture was taken "Channels" - the number of color channels used in the file
"ColorProfileData" embedded color profile, given as a ColorProfileData object "ColorSpace" color encoding used in the file "FlashUsed" - whether the flash was fired
"GeoPosition" latitude and longitude represented as a GeoPosition object "GPSDateTime" - image creation date and time registered by GPS
"ImageSize" raster dimensions "RedEyeCorrection" whether a red-eye correction was performed "Summary" - summary of the file
- Metadata elements:
-
"Exif" formatted Exif (Exchange image file format) "IPTC" formatted IPTC (International Press Telecommunications Council) "XMP" formatted XMP (Extensible metadata platform) "MetaInformation" combination of all formatted metadata present in the file - Raw metadata, as stored in the file, can be imported using "RawExif", "RawXMP" and "RawIPTC" elements which are returned in an association.
- All Exif and IPTC tags can be imported individually. Common tags include:
-
"ApertureValue" lens aperture "Artist" photographer or image creator "DateTime" image creation date and time "ExposureTime" exposure time, given in seconds "FlashInfo" - flash information: flash fired, red-eye correction, etc.
"FNumber" F number "FocalLength" actual focal length of the lens, given in millimeters "GPSAltitude" altitude of the GPS position "GPSLatitude" latitude of the GPS position "GPSLongitude" longitude of the GPS position "Make" manufacturer of the recording equipment "Model" model name or model number of the equipment "Software" name and version of the software or firmware of the camera or image input device used to generate the image
Options

- Import and Export options:
-
ImageResolution Automatic resolution values for import and export ImageSize Automatic overall image size IncludeMetaInformation All metadata types to import and export "ImageTopOrientation" Automatic orientation of the image as stored in the file - Import option:
-
"TakeRows" {1,-1} rows to import - Export options:
-
ColorSpace "RGB" color space to be used in the file CompressionLevel 0.25 sets the JPEG compression parameter "Progressive" False whether to store the image in a way that allows progressive display while the file is being loaded "Smoothing" 0 the JPEG smoothing parameters, given as a number in the range 0 (no smoothing) to 1 ImageFormattingWidth $ImageFormattingWidth target width when formatting an object - Supported ColorSpace settings are: "Grayscale", "RGB", and "CMYK". Using ColorSpace->Automatic, Export attempts to create a JPEG file with the same color space.
- The value of CompressionLevel can be in the range from 0 to 1, with larger values resulting in smaller file sizes but lower-quality encodings.
Examples
open allclose allBasic Examples (3)
Scope (3)
Import Elements (35)
Available Elements (5)
Data Representation (7)
Metadata (23)
"CameraTopOrientation" (2)
Get the camera orientation at the capture time:
The image is auto-rotated on Import:
An auto-rotated image has an updated Exif tag:
Avoid auto-rotation by setting the "ImageTopOrientation" option:
"ColorProfileData" (1)
Get the embedded color profile, given as a ColorProfileData object:
The color profile is stored in the ColorSpace option of the imported image:
"ColorSpace" (1)
Get the color encoding used on export:
Use ImageColorSpace to get the color space of an imported image:
"Exif" (3)
"FlashUsed" (1)
"GeoPosition" (2)
"ImageSize" (1)
Get the dimensions of the image stored in the file:
Using ImageDimensions on an imported image gives the same result:
"RawExif" (1)
"RawIPTC" (1)
"RawXMP" (1)
Import Options (7)
ImageResolution (1)
ImageSize (1)
"ImageTopOrientation" (1)
IncludeMetaInformation (3)
Export Options (7)
"ColorSpace" (1)
CompressionLevel (2)
ImageSize (1)
ImageResolution (1)
"ImageTopOrientation" (1)
By default, the upright image is exported using "ImageTopOrientation"->Top: