JPEG (.jpg, .jpeg)

  • Import and Export fully support the JPEG standard.
  • Import also supports parts of the Exif 2.2 metadata standard.
  • BackgroundBackground

      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 and ExportImport and 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 InterfaceNotebook 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.

    ElementsElements

    • 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
      "GrayLevels"array of normalized gray-level values
      "Image"raster image, given as an Image object
      "RawData"array of color map indices
      "RGBColorArray"array of RGBColor objects
      {"Thumbnail",size}thumbnail of the first image (default size = Small)
    • Import and Export by default use the element for the JPEG format.
    • Advanced Import elements:
    • "BitDepth"bits used to represent each color channel in the file
      "ColorProfileData"embedded color profile, given as a ColorProfileData object
      "ColorSpace"color encoding used in the file
      "Exif"all Exif tags, given as a list of rules
      "ImageSize"raster dimensions
    • Advanced Import elements include:
    • "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 DateObject
      "Aperture"aperture setting at which the picture was taken, given in APEX units
      "ISOSpeed"ISO 12232 speed rating of the camera or input device
    • For the element, the Exif tags are embedded using the MetaInformation option of the imported Image object under the name . The embedded Exif tags are automatically exported when exporting as JPEG.

    OptionsOptions

    • General option:
    • ImageSizeAutomaticoverall image size
    • Import and Export option:
    • "ImageTopOrientation"Automaticorientation of the image as stored in the file
    • Import option:
    • "TakeRows"{1,-1}rows to import
    • Export options:
    • "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
      ImageFormattingWidth$ImageFormattingWidthtarget width when formatting an object
    • With a setting "ColorSpace"->Automatic, the Wolfram Language attempts to create a JPEG file that has the same color space as the image to be exported. JPEG can store images with , , or color spaces.
    • 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.

    ExamplesExamplesopen allclose all

    Basic Examples  (3)Basic Examples  (3)

    Import a JPEG image as an image:

    In[1]:=
    Click for copyable input
    Out[1]=

    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]=
    Introduced in 1999
    (4.0)
    | Updated in 2015
    (10.3)
    Translate this page: