glexif

Read standard EXIF metadata from JPEG APP1 segments.

Types

A file-level failure that prevented EXIF metadata from being read safely.

Unsupported or malformed optional tags are skipped when the surrounding JPEG, TIFF header, and IFD structure remain valid.

pub type ExifError {
  FileOpenError(message: String)
  FileReadError(message: String)
  FileCloseError(message: String)
  InvalidJpegHeader
  ExifMarkerNotFound
  UnexpectedEndOfFile
  InvalidSegmentSize(size: Int)
  InvalidExifHeader
  InvalidTiffHeader
  InvalidEntry(offset: Int)
  InvalidOffset(offset: Int)
  OffsetCycle(offset: Int)
  TraversalLimitExceeded
}

Constructors

  • FileOpenError(message: String)

    The file could not be opened.

  • FileReadError(message: String)

    The opened file could not be read.

  • FileCloseError(message: String)

    Parsing succeeded, but the opened file could not be closed.

  • InvalidJpegHeader

    The file does not start with a JPEG start-of-image marker.

  • ExifMarkerNotFound

    No Exif-prefixed APP1 candidate was present before image data.

  • UnexpectedEndOfFile

    The file ended while a complete JPEG segment was being read.

  • InvalidSegmentSize(size: Int)

    A JPEG segment declared an invalid size.

  • InvalidExifHeader

    A standard EXIF APP1 segment had an invalid EXIF header.

  • InvalidTiffHeader

    The TIFF byte order, magic value, or header was invalid.

  • InvalidEntry(offset: Int)

    An IFD table or structural entry was invalid.

  • InvalidOffset(offset: Int)

    A structural TIFF offset was outside the EXIF segment.

  • OffsetCycle(offset: Int)

    Linked IFDs revisited an offset that had already been parsed.

  • TraversalLimitExceeded

    Parsing exceeded the work permitted by the EXIF segment size.

Values

pub fn error_to_string(error: ExifError) -> String

Format an EXIF error for logs or user-facing diagnostics.

pub fn get_exif_data_for_file(
  file_path: String,
) -> Result(exif_tag.ExifTagRecord, ExifError)

Read EXIF metadata from a JPEG file without panicking for invalid input.

A readable JPEG with no Exif-prefixed APP1 candidate returns Error(ExifMarkerNotFound). A malformed candidate returns the applicable EXIF or TIFF error instead.

Search Document