JPEGMetadata (extract EXIF)
ts
function JPEGMetadata(imgFile: string): object;Extracts meta-information (including full EXIF data) from a JPEG image file.
Parameters
| Name | Type | Description |
|---|---|---|
| imgFile | string | Path to the JPEG image file to be analyzed. |
Returns
A JSON object containing EXIF and other metadata fields. If extraction fails or the file is not a valid JPEG, an empty object is returned.
NOTE
The returned object may include fields such as Exif, Height, Width, and Valid. The exact fields depend on the image and its metadata. Some JPEGs may not contain EXIF data.
Example
ts
var mdata = JPEGMetadata('./self_portrait.jpg');
Log(JSON.stringify(mdata, null, 2));Example output:
json
{
"Exif": {
"ApertureValue": ["149/32"],
"ColorSpace": [1],
"DateTime": "2003:12:14 12:01:44",
"Make": "Canon",
"Model": "Canon PowerShot S40",
// ... more EXIF fields ...
},
"Height": 360,
"Valid": true,
"Width": 480
}TIP
For best results, ensure the input file is a valid JPEG with embedded EXIF metadata. Some image editors or converters may strip EXIF data from JPEGs.
