Main Content


Read metadata from RAW file



    info = rawinfo(filename) reads metadata from a RAW file specified by filename.


    collapse all

    Retrieve metadata from a RAW image file.

    info = rawinfo("colorCheckerTestImage.NEF");

    Examine the CFALayout field to determine the sensor layout.

    sensor_layout = info.CFALayout
    sensor_layout = 

    Input Arguments

    collapse all

    Name of RAW file, specified as a string scalar or char vector. Specify filename as a full path, containing the file name and extension, or as a relative path from the current folder or from any folder on the MATLAB path.

    Data Types: char | string

    Output Arguments

    collapse all

    Metadata from the RAW file, returned as a struct with these fields.

    FilenameString scalar specifying the full name, including the path, to the RAW image file.

    String scalar specifying the type of the sensor that captured the image. rawinfo supports these sensors: "Bayer", "Fuji X-Trans", "Foveon", "Fuji Super-CCD", and "Non-Bayer".

    CFALayoutString scalar specifying the sensor layout for Bayer sensors. Sensor layouts supported by rawinfo include but are not limited to "BGGR", "RGGB", "GBRG", and "GRGB". For non-Bayer sensors, this value is empty.
    CFAImageSizeTwo-element row vector of type double specifying the total number of rows and columns present in the CFA image.
    SamplesPerPixelScalar of type double specifying the number of samples in every pixel of the image.
    ImageSizeInfoStructure containing all the size information that describes a CFA image.
    ColorInfoStructure containing all of the color information required to render an RGB image from the CFA image.
    ExifTagsStructure containing the EXIF Tags, if any, present in the file. The Makernotes, if any, are included in this field.
    LensInfoStructure containing information about the lens used to capture the image.
    MiscInfoStructure containing information, if any, about the camera and image creator present in the file.
    XMPDataString scalar containing the Adobe Extensible Metadata Platform (XMP) data, if any, present in the file.
    FormatSpecificInfoStructure containing format specific information, such as DNG Tags and X-Trans sensor layout descriptions. If no format specific information is available, this value is an empty structure.
    LibrawVersionString scalar specifying the version of the LibRaw library currently being used. LibRaw is a library for reading RAW files obtained from digital photo cameras. For more information, see


    • The rawinfo function does not support RAW file formats that employ JPEG compression.

    More About

    collapse all

    Information about the RAW File Format

    The RAW file format preserves image data in its most unedited state, recorded directly from the camera sensor. Most camera manufacturers define their own proprietary RAW file format, such as the Nikon NEF file format and the Canon CRW format. Adobe has also defined a RAW file format, DNG (digital negative), which is supported by several cameras. The name of the format is typically capitalized, like other file formats such as JPG and TIF. However, unlike other file formats, RAW is not an acronym.


    • The function uses LibRaw version 0.20.0 for reading the CFA image data.

    Introduced in R2021a