This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

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.
Supports 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 also supports parts of the Exif 2.2 metadata standard.
  • Import imports a JPEG file and returns an image.
  • Export exports an image, graphics, or any other expression as a raster image to JPEG.
  • When exporting Mathematica graphics or arbitrary expressions to JPEG, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because JPEG is a raster image format, all fonts are rasterized on export.
  • Import imports the specified element from a JPEG file.
  • Import imports multiple elements.
  • Export creates a JPEG file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • Export 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
"Image"raster image, given as an Image object
"GrayLevels"array of normalized gray-level values
"RGBColorArray"array of RGBColor objects
"RawData"array of indexed colors
  • Import and Export by default use the 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
  • 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
"ColorSpace""RGB"color encoding to be used in the file
"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
"Smoothing"0the JPEG smoothing parameters, given as a number in the range 0 to 1
  • With a setting Automatic, Mathematica attempts to create a JPEG file that has the same color space as the image to be exported. For a list of possible settings, see the reference page for ColorConvert.
  • When exporting a raster image to JPEG, no smoothing filter is applied by default.
  • 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.
Import a JPEG image as an image:
Get the pixel dimensions of this photo:
Show all Import elements available in the file:
Import metadata elements:
Read raw color data from the file and extract the first few pixels:
Export an RGB image to JPEG:
Export a CMYK image:
Import a JPEG image as an image:
In[1]:=
Click for copyable input
Out[1]=
Get the pixel dimensions of this photo:
In[2]:=
Click for copyable input
Out[2]=
Show all Import elements available in the file:
In[3]:=
Click for copyable input
Out[3]=
Import metadata elements:
In[4]:=
Click for copyable input
Out[4]=
 
Read raw color data from the file and extract the first few pixels:
In[1]:=
Click for copyable input
Out[1]=
 
Export an RGB image to JPEG:
In[1]:=
Click for copyable input
Out[1]=
 
Export a CMYK image:
In[1]:=
Click for copyable input
Out[1]=