module

CrImage::EXIF

EXIF (Exchangeable Image File Format) metadata parser.

Supports reading EXIF metadata from JPEG, TIFF, and WebP images. EXIF data uses TIFF structure internally.

Supported Tags

  • Orientation (auto-rotation)
  • DateTime, DateTimeOriginal, DateTimeDigitized
  • Make, Model (camera info)
  • GPS coordinates
  • Image dimensions
  • Software, Artist, Copyright

Example

exif = CrImage::EXIF.read("photo.jpg")
puts exif.orientation # => 6 (rotate 90° CW)
puts exif.date_time   # => 2024-01-15 10:30:00
puts exif.camera      # => "iPhone 15 Pro"

Constants

BIG_ENDIAN = "MM".to_slice
DATA_TYPE_SIZES = {DataType::Byte => 1, DataType::ASCII => 1, DataType::Short => 2, DataType::Long => 4, DataType::Rational => 8, DataType::SByte => 1, DataType::Undefined => 1, DataType::SShort => 2, DataType::SLong => 4, DataType::SRational => 8, DataType::Float => 4, DataType::Double => 8}

Size in bytes for each data type

EXIF_SIGNATURE = "Exif\u0000\u0000".to_slice

EXIF signature in JPEG APP1 segment

IFD_ENTRY_SIZE = 12

IFD entry size in bytes

LITTLE_ENDIAN = "II".to_slice

TIFF byte order markers

TIFF_MAGIC = 42_u16

TIFF magic number

Class methods

read(path : String) : Data | Nil

Module-level convenience methods

Source
read(io : IO) : Data | Nil
Source
read_jpeg(io : IO) : Data | Nil
Source
read_tiff(io : IO) : Data | Nil
Source
read_webp(io : IO) : Data | Nil
Source

Nested types