EXIF metadata reader and writer for PascalAI. Read GPS coordinates, camera settings, orientation, timestamps, and lens data from JPEG photos. Edit or strip metadata for privacy. The standard library used by photo management and geotagging tools.
uses libexif;
{ Strip EXIF for privacy before publishing }StripEXIF('/private/photo.jpg', '/public/photo.jpg');
{ Fix orientation (rotate pixel data based on EXIF tag) }FixOrientation('/input/photo.jpg', '/output/photo.jpg');
{ Export all metadata as JSON }var exif := LoadFromFile('/photos/photo.jpg');
var json := ToJSON(exif);
WriteLn(json);
FreeData(exif);
Load / Save API
All operations work on an opaque TExifData handle. Always call FreeData when done to release memory.
Function
Description
LoadFromFile(path)
Load EXIF data from a JPEG file. Returns TExifData handle.
LoadFromBytes(data)
Load EXIF from an in-memory byte array (JPEG data).
SaveToFile(exif, srcPath, dstPath)
Write modified EXIF back into a new JPEG file.
SaveInPlace(exif, path)
Overwrite the EXIF segment of an existing JPEG file.
FreeData(exif)
Release memory for a TExifData handle.
HasEXIF(path)
Returns True if the JPEG file contains an EXIF segment.
Reading Entries API
Low-level access to individual EXIF tags by numeric ID or name. Use the Structured Access API below for common fields.
Function
Description
GetEntryString(exif, tagId)
Read tag value as a formatted string. Returns empty string if not present.
GetEntryInt(exif, tagId)
Read tag value as integer. Raises exception if tag absent.
GetEntryFloat(exif, tagId)
Read rational tag (e.g. exposure time) as floating-point.
GetEntryBytes(exif, tagId)
Read tag raw bytes.
HasEntry(exif, tagId)
Returns True if tag exists in any IFD.
ListTags(exif)
Returns array of all tag IDs present.
TagName(tagId)
Human-readable tag name for a numeric ID. E.g. 0x010F → 'Make'.
uses libexif;
var exif := LoadFromFile('photo.jpg');
{ Low-level tag reads }var make := GetEntryString(exif, $010F); { Make }var iso := GetEntryInt(exif, $8827); { ISOSpeedRatings }var exp := GetEntryFloat(exif, $829A); { ExposureTime }WriteLn('Make: ' + make);
WriteLn('ISO: ' + IntToStr(iso));
WriteLn('Exposure: ' + FloatToStr(exp) + 's');
{ List all tags }var tags := ListTags(exif);
for var tid in tags doWriteLn(TagName(tid) + ': ' + GetEntryString(exif, tid));
FreeData(exif);
Structured Access API
High-level functions that parse common EXIF groups into typed records.
Function
Description
GetGPS(exif)
Returns TExifGPS with latitude, longitude, altitude, heading, and speed.
GetCameraInfo(exif)
Returns TExifCameraInfo with make, model, ISO, aperture, shutter, focal length.
GetDateTime(exif)
Returns TDateTime parsed from the DateTimeOriginal tag.
GetDateTimeStr(exif)
Returns DateTimeOriginal as a string in 'YYYY:MM:DD HH:MM:SS' format.
GetOrientation(exif)
Returns orientation value 1–8 (EXIF rotation/flip code).
GetThumbnail(exif)
Returns embedded JPEG thumbnail as byte array, or empty if absent.
GetSoftware(exif)
Software tag value (editing app name, e.g. 'Lightroom').
Copy JPEG removing all metadata. Output is clean for publishing.
FixOrientation(srcPath, dstPath)
Rotate/flip pixel data to match orientation tag, then clear tag.
ToJSON(exif)
Serialize all EXIF tags to a JSON string.
FromJSON(json)
Create a TExifData handle populated from a JSON string.
CopyEXIF(srcPath, dstPath)
Copy EXIF segment from srcPath into dstPath (must both be JPEG).
EXIFVersion()
Returns libexif library version string.
TExifGPS Record
Field
Type
Description
HasGPS
Boolean
False if no GPS IFD present in file.
Latitude
Double
Decimal degrees. Negative = South.
Longitude
Double
Decimal degrees. Negative = West.
Altitude
Double
Meters above sea level. Negative if below.
Heading
Double
True north heading in degrees (0–360), or -1 if absent.
Speed
Double
Speed in km/h at capture time, or -1 if absent.
Timestamp
String
GPS timestamp string 'HH:MM:SS'.
Datestamp
String
GPS datestamp string 'YYYY:MM:DD'.
TExifCameraInfo Record
Field
Type
Description
Make
String
Camera manufacturer (e.g. 'Apple', 'Canon', 'Sony').
Model
String
Camera model string (e.g. 'iPhone 15 Pro', 'EOS R5').
LensMake
String
Lens manufacturer, if present.
LensModel
String
Lens model string, if present.
ISO
Integer
ISO speed (e.g. 100, 800, 3200).
Aperture
Double
F-number (e.g. 1.8, 4.0, 11.0).
ShutterSpeed
Double
Exposure time in seconds (e.g. 0.001 = 1/1000s).
FocalLength
Double
Focal length in mm.
FocalLength35mm
Integer
35mm-equivalent focal length, or 0 if absent.
ExposureMode
String
'Auto', 'Manual', or 'Auto bracket'.
ExposureProgram
String
'Normal', 'Aperture priority', 'Shutter priority', etc.
MeteringMode
String
'Matrix', 'Center-weighted', 'Spot', etc.
Common EXIF Tag IDs
Tag ID
Name
Description
0x010F
Make
Camera manufacturer string.
0x0110
Model
Camera model string.
0x0112
Orientation
1–8 rotation/flip code.
0x011A
XResolution
Horizontal resolution (DPI).
0x011B
YResolution
Vertical resolution (DPI).
0x0132
DateTime
File modification date/time.
0x013B
Artist
Photographer name.
0x8298
Copyright
Copyright string.
0x829A
ExposureTime
Shutter speed as rational (e.g. 1/1000).
0x829D
FNumber
F-number (aperture) as rational.
0x8827
ISOSpeedRatings
ISO sensitivity value.
0x9003
DateTimeOriginal
Original capture date/time.
0x9004
DateTimeDigitized
Date/time image was digitized.
0x920A
FocalLength
Focal length in mm.
0xA405
FocalLengthIn35mmFilm
35mm-equivalent focal length.
0xA432
LensSpecification
Min/max focal length and aperture.
0xA434
LensModel
Lens model string.
0x8825
GPSInfo
Offset to GPS sub-IFD.
Memory management
Every LoadFromFile or LoadFromBytes call allocates a handle. Always call FreeData(exif) when finished. Handles are not garbage-collected automatically.