This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
Mathematica Import/Export Format

JPEG (.jpg, .jpeg)

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.
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 also supports parts of the Exif 2.2 metadata standard.
  • Import["file.jpg"] imports a JPEG file, returning a graphics object.
  • Export["file.jpg", expr] exports graphics or any other expression as an image to a JPEG file.
  • Import["file.jpg"] returns an expression of the form Graphics[Raster[data], opts], where data is an array of RGB color values.
  • Export["file.jpg", expr] creates a JPEG image with the same image size as the displayed form of expr.
  • Because JPEG is a raster image format, all fonts are rasterized on export.
  • Import["file.jpg", elem] imports the specified element from a JPEG file.
  • Import["file.jpg", {elem, suba, subb, ...}] imports a subelement.
  • Import["file.jpg", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "JPEG"] or Import["file", {"JPEG", elem, ...}].
  • Export["file.jpg", expr, elem] creates a JPEG file by treating expr as specifying element elem.
  • Export["file.jpg", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each expri as specifying the corresponding elemi.
  • Export["file.jpg", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.jpg", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • In the notebook front end, InsertPicture and the Open menu allow the import of a JPEG file into a cell.
"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 created on import
"Data"array of color values taken
"Graphics"Graphics object representing an image
"GrayLevels"array of normalized gray-level values
"RawData"array of indexed colors
"RGBColorArray"array of RGBColor objects
  • Import and Export by default use the "Graphics" element for the JPEG format.
"BitDepth"bits used to represent each color channel in the file
"ColorSpace"color encoding used in the file
"ImageSize"raster dimensions
"Exif"all Exif tags given as a list of rules
  • Individual Exif tags (available for Import):
"FocalLength"focal length in millimeters
"CameraTopOrientation"orientation of the camera when the picture was taken
"Manufacturer"maker of the camera or input device
"Model"model specification of the camera or input device
"Exposure"photographic exposure time in seconds
"Date"date and time the original picture was taken, given as a DateList specification
"Aperture"aperture setting at which the picture was taken, given in APEX units
"ISOSpeed"ISO 12232 speed rating of the camera or input device
  • General option:
ImageSizeAutomaticoverall image size
"ImageTopOrientation"Toporientation of the image as stored in the file
"ColorMap"Nonespecifies the color reduction palette used for representing the imported JPEG
"DitheringMethod""FloydSteinberg"the dithering method used when color reduction is performed on Import
  • The following settings can be given for "ColorMap":
Automaticchooses an adaptive set of at most 256 colors using the median cut algorithm
nadaptive set of at most n colors
{color1,color2,...}list of color primitives
Noneno color reduction is performed
  • The "DitheringMethod" option specifies the dithering algorithm used for generating the color-reduction palette on Import:
"FloydSteinberg"Floyd-Steinberg error diffusion dithering
"Ordered"ordered dithering algorithm
Noneno dithering is used
"ImageTopOrientation"Toporientation of the exported image
"Smoothing"0the JPEG smoothing parameter, given as a number in the range 0 to 1
  • When exporting a raster image to JPEG, no smoothing filter is applied by default.
  • Detailed properties and settings:
"ColorSpace"RGBColorcolor space of the image
"CompressionLevel"0.25sets the JPEG compression parameter
"Progressive"Falsewhether to store the image in a way that allows progressive display while the file is being loaded
  • "CompressionLevel" can be set to values in the range from 0 to 1, with larger values resulting in smaller file sizes.
  • Since JPEG uses a lossy compression method, higher compression levels correspond to lower-quality encodings.