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

Documentation / Mathematica / Built-in Functions / Graphics and Sound / Import and Export /

Additional Information: Import

Many Import formats have private options that are specified using the option ConversionOptions: Import["file", "format", ConversionOptions -> opts].

BMP

Import supports Windows device-independent bitmaps that are compressed using run-length encoding.

CSV

The following options can be given:

FilledSmallSquare Setting "Numeric" to False stores numbers as their string textual representations.

FilledSmallSquare The option "DateStyle" can be set to the values "American", "European", or "Scientific".

FilledSmallSquare A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction".

FilledSmallSquare A date field will be broken into a list of the form year, month, day.

FilledSmallSquare The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function.

FilledSmallSquare Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits.

FilledSmallSquare When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date.

FilledSmallSquare User-defined functions for "TwoDigitYearFunction" must return Integer values.

DICOM

The following options can be given:

FilledSmallSquare Import supports files in the DICOM file format as specified in Section PS 3.10 of the DICOM standard and the ACR/NEMA 2.0 file format.

FilledSmallSquare The ConversionOption "Verbose" determines the form of the output.

FilledSmallSquare With "Verbose" False, the output is a Graphics expression created from the Pixel Data and Overlays.

FilledSmallSquare With "Verbose" True, the output is a list of Data Elements of the form DataElementTag value, ... .

FilledSmallSquare Pixel Data for most JPEG Transfer Syntaxes (all except Baseline Encoding, 1.2.840.10008.1.2.4.50) is not parsed. With "Verbose" False, the output is $Failed. With "Verbose" True, the Pixel Data is a JPEG string.

FilledSmallSquare The ConversionOption "DataDictionary" determines the names used for Data Element Tags when "Verbose" True.

FilledSmallSquare With "DataDictionary" Automatic, all Data Elements Tags in Section PS 3.6 of the DICOM Standard are replaced with string names. All other Data Element Tags are left as "Group Number", "Element Number" pairs.

FilledSmallSquare With "DataDictionary" None, all Data Elements Tags are left as "Group Number", "Element Number" pairs.

FilledSmallSquare A different set of names can be set using "DataDictionary" "Group Number", "Element Number" "name", ... .

FilledSmallSquare The ConversionOption "ImplicitVRs" determines how a Data Element Value is parsed when "Verbose" True and the Data Elements use Implicit Value Representations (VRs).

FilledSmallSquare If the Data Elements use Explicit VR, then the VR in the file will be used and the setting for "ImplicitVRs" is ignored.

FilledSmallSquare With "ImplicitVRs" Automatic, all Implicit VRs in section PS 3.6 of the DICOM Standard are used. All other Data Elements are parsed with an unknown ("UN") VR.

FilledSmallSquare A different set of Implicit VRs can be set using "ImplicitVRs" "Group Number", "Element Number" "vr", ... .

FilledSmallSquare Allowed VRs include "AE", "AS", "AT", "CS", "DA", "DS", "DT", "FL", "FD", "IS", "LO", "LT", "OB", "OW", "PN", "SH", "SL", "SQ", "SS", "ST", "TM", "UI", "UL", "UN", "US", and "UT".

ExpressionML

The following option can be given:

FilledSmallSquare See also the options listed for "SymbolicXML".

FITS

The following option can be given:

FilledSmallSquare The option "Verbose" determines whether header information is imported. It also determines the format of the imported data.

FilledSmallSquare With "Verbose" False, header information is not imported.

FilledSmallSquare With "Verbose" False, data is formatted as a list of matrices, even if the data comes from multiple Header Data Units (HDUs). This allows for easy plotting by mapping the data with functions like ListDensityPlot and ListContourPlot.

FilledSmallSquare With "Verbose" True, import returns a list of HDUs. Each HDU is a list containing a header and a data unit.

FilledSmallSquare With "Verbose" True, each header is a list of entries of the form _String "Value" _, "Comment" _String. This allows programmatic access to values and comments in the headers.

FilledSmallSquare The value of a header entry named ent can be extracted from a header named head with the following: "Value"/.(ent/.head). The comment can be extracted with "Comment"/.(ent/.head).

FilledSmallSquare With "Verbose" True, data is not returned as a list of matrices, but as tensors paired in lists with their headers. A 0-dimensional tensor is represented by Null.

FilledSmallSquare The primary HDU and IMAGE extensions are imported as integer or real data.

FilledSmallSquare ASCII table extensions are imported as string data.

FilledSmallSquare Other extensions are not supported.

GIF

The following options can be given:

FilledSmallSquare The option "ColormapOutput" determines whether a GIF is imported as a Raster graphics primitive with a color map ColorFunction and a matrix of indices into the color map, or whether the imported Raster graphics primitive contains a normal matrix of sample values. A grayscale image will import without the use of a color map ColorFunction.

FilledSmallSquare If the GIF is an animated GIF with multiple frames, "ImageIndex" -> i will select a particular frame to import. "ImageIndex" -> , , ... will select a list of frames from the animated GIF. By default, all frames of an animated GIF are imported.

HarwellBoeing

Import of "HarwellBoeing" formatted sparse matrices must be done by explicitly including the format keyword "HarwellBoeing", i.e., in the form Import["file", "HarwellBoeing"].

HDF

The following option can be given:

FilledSmallSquare HDF files can contain multiple datasets in a single file. By default, the first dataset in an HDF file is imported. "DatasetSelection" -> i will attempt to import the dataset at index i. "DatasetSelection" -> string will attempt to find a dataset named with label string. "DatasetSelection" -> Information will not import the datasets in the file but will instead return a list of length equal to the number of datasets in the file and contain information about the format types, names, and dimensions of the datasets.

FilledSmallSquare Import of HDF currently only supports the "scientific datasets" SDS interface.

JPEG

The following options can be given:

FilledSmallSquare Although the JPEG format is not stored as a color-mapped image, Import can color reduce or quantize the JPEG as it is being imported. By default, no color reduction is done.

FilledSmallSquare Using a "ColorReductionDither" method can provide better resulting images once a color map is chosen by dithering the resulting image. "ColorReductionDither" -> "Ordered" provides relatively fast and medium-quality dithering, while "ColorReductionDither" -> "Floyd-Steinberg" provides the best-quality error-diffusion dithering, requiring more time and memory. "ColorReductionDither" -> None will perform no dithering on the imported image.

FilledSmallSquare "ColorReduction" -> "Fixed" chooses evenly spaced colors from a color space, which may not pick the most optimal colors for the image. "ColorReduction" -> "Adaptive" uses a median-cut algorithm to choose the optimal set of colors for an image.

FilledSmallSquare "ColorReductionPalette" -> Automatic will choose an adaptive set of at most 256 colors. "ColorReductionPalette" -> n will choose at most n colors for the color palette. "ColorReductionPalette" -> , , ... specifies a list of color directives to use to color reduce the image. The values for must be CMYKColor, GrayLevel, Hue, or RGBColor directives. The number of colors chosen for "ColorReductionPalette" must be between 2 and 256.

FilledSmallSquare The following example produces an image using a color map of "browser safe" 216 colors: Import["file.jpg", "JPEG", ConversionOptions -> {"ColorReduction" -> "Fixed", "ColorReductionPalette" -> 216}].

FilledSmallSquare Color reduction of JPEG images only applies to JPEG images with three color components. If you are producing these JPEG images yourself, you can force the use of three color components with Export and "Colorspace" -> "RGBColor": Export["file.jpg", gr, "JPEG", ConversionOptions->{"Colorspace" -> RGBColor}].

FilledSmallSquare The option "Colorspace" can be explicitly set to RGBColor or GrayLevel to force the resulting imported image to a specific color space.

List

The following options can be given:

FilledSmallSquare The options of the List format act the same as the options of the Table format.

MathML

The following option can be given:

FilledSmallSquare See also the options listed for "SymbolicXML".

MTX

Import supports files in the MatrixMarket exchange formats described at math.nist.gov/MatrixMarket/formats.html#MMformat.

When the file is in MatrixMarket coordinate format, the result will be a SparseArray.

When the file is in MatrixMarket array format, the result will be a PackedArray.

MPS

Import of "MPS" covers two standards, MPS optimization problems and Mathematica PostScript.

Using the "MPS" format determines the file type and then does the appropriate import.

The following option can be given when importing MPS optimization problems:

FilledSmallSquare With "FreeFormat" False, the data file can have up to six fields in predefined positions.

FilledSmallSquare With "FreeFormat" True, the data entries do not have to reside at predefined positions. A contiguous sequence of non-whitespace characters is treated as a field.

NotebookML

The following option can be given:

FilledSmallSquare See also the options listed for "SymbolicXML".

PBM, PGM, PPM, PNM

The following options can be given:

FilledSmallSquare "CheckDepth" -> True will check the data on importing to see if the actual data stored in the image could be represented by a reduced color space. For example, if a PPM file contains identical red, green, and blue components for all pixels, a Raster of gray levels is imported.

FilledSmallSquare Although the PBM formats are not stored as a color-mapped image, Import can color reduce or quantize the PBM as it is being imported. By default, no color reduction is done. "ColorReduction" -> True will perform color quantization.

FilledSmallSquare By dithering the resulting image, "ColorReductionDither" -> True will provide better resulting images once a color map is chosen.

FilledSmallSquare "ColorReductionPalette" -> Automatic will choose an adaptive set of at most 256 colors. "ColorReductionPalette" -> n will choose at most n colors for the color palette. "ColorReductionPalette" -> , , ... specifies a list of color directives to use to color reduce the image. The values for must be CMYKColor, GrayLevel, Hue, or RGBColor directives. The number of colors chosen for "ColorReductionPalette" must be between 2 and 256.

SDTS

The following options can be given:

FilledSmallSquare The option "FillValue" is used when importing nonrectangular data. Since every dataset is rectangular, there will be data points that do not correspond to any physical data. "FillValue" specifies what integer value is used in Mathematica to represent these data points. Adjusting the "FillValue" can improve the contrast with other data points when plotting the data.

FilledSmallSquare The option "ElementSkip" n is an optimization which specifies to only import every row and column of the dataset. This reduces the timing for Import and other functions acting on the imported data. This is useful when the dataset has a greater resolution than required.

FilledSmallSquare Only import of Digital Elevation Models (DEM) are supported. Most DEM data in SDTS format come in gzipped tar archives. The DEM data is contained in a single file in the archive, named ????CEL0.DDF.

SymbolicXML

The following options can be given:

Table

The following options can be given:

FilledSmallSquare The option "DateStyle" can be set to the values "American", "European", or "Scientific".

FilledSmallSquare A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction".

FilledSmallSquare A date field will be broken into a list of the form year, month, day.

FilledSmallSquare The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function.

FilledSmallSquare Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits.

FilledSmallSquare When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date.

FilledSmallSquare User-defined functions for "TwoDigitYearFunction" must return Integer values.

TIFF

The following options can be given:

FilledSmallSquare "CheckDepth" -> True will check the data on importing to see if the actual bit depth of the TIFF is smaller than one byte per image sample, and this can result in a Raster with integer values scaled to a more exact representation of what was stored in the TIFF. For example, a 4-bit TIFF image would be imported as a Raster with a matrix of integer values between 0 and 15 and not the normal 0 to 255 associated with a byte of image sample information.

FilledSmallSquare If the TIFF contains multiple images, "ImageIndex" -> i will select a particular image to import. "ImageIndex" -> , , ... will select a list of images from the TIFF. By default, all images of a TIFF are imported.

TSV

The following options can be given:

FilledSmallSquare Setting "Numeric" to False stores numbers as their string textual representations.

FilledSmallSquare The option "DateStyle" can be set to the values "American", "European", or "Scientific".

FilledSmallSquare A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction".

FilledSmallSquare A date field will be broken into a list of the form year, month, day.

FilledSmallSquare The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function.

FilledSmallSquare Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits.

FilledSmallSquare When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date.

FilledSmallSquare User-defined functions for "TwoDigitYearFunction" must return Integer values.

XML

See the options listed for "SymbolicXML".