PHPackages                             szalayk/get-exif - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. szalayk/get-exif

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

szalayk/get-exif
================

EXIF reader + human-friendly formatter for photographers. Returns raw and formatted exposure and other EXIF fields.

v1.0.0(5mo ago)00MITPHPPHP &gt;=8.1

Since Nov 23Pushed 5mo agoCompare

[ Source](https://github.com/szalayk/getexif)[ Packagist](https://packagist.org/packages/szalayk/get-exif)[ RSS](/packages/szalayk-get-exif/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

GetExif
=======

[](#getexif)

A lightweight, dependency-free EXIF reader with human-friendly formatting. Designed for photographers who want clean, readable exposure data.

Created by **Krisztian Szalay**.

---

Features
--------

[](#features)

- Read EXIF metadata from JPEG files:
    - camera model
    - focal length
    - aperture
    - shutter speed
    - ISO
    - orientation
    - creation date
    - GPS (converted to decimal lat/lng)
- Returns **both raw** EXIF strings and **human-formatted** values.
- Exposure formatting modes:
    - **raw** – original EXIF values (`280/10`)
    - **human** – clean numeric values (`28`, `4.6`, `1/125`)
    - **human\_with\_units** – photographer-friendly (`28 mm`, `f/4.6`, `1/125 s`)
- Robust date extraction with fallback chain: **DateTimeOriginal → DateTimeDigitized → DateTime**
- Optional: keep full raw EXIF arrays in the output.
- Simple and tiny — ideal for hobby, portfolio, or micro-CMS photo systems.

---

Requirements
------------

[](#requirements)

- **PHP 8.1+**
- PHP **exif** extension
- PHP **gd** extension (optional, only needed for orientation tools)
- Composer

> Note: PNG, WebP and many web formats do *not* contain EXIF metadata.

---

Installation
------------

[](#installation)

```
composer require szalayk/get-exif
```

---

Basic usage
-----------

[](#basic-usage)

```
use Szalayk\GetExif\GetExif;

$g = new GetExif();

// Read only exposure data, formatted with units
$data = $g->read('/path/to/photo.jpg', [
    'fields' => GetExif::FIELDS_EXPOSURE,
    'format' => GetExif::FORMAT_HUMAN_WITH_UNITS
]);

print_r($data);
```

---

Full Example (all fields)
-------------------------

[](#full-example-all-fields)

```
$data = $g->read('/path/to/photo.jpg', [
    'fields' => GetExif::FIELDS_ALL,
    'format' => GetExif::FORMAT_HUMAN,
    'keep_raw_keys' => true
]);

echo $data['created'];       // "2020-05-26 14:32:18"
echo $data['camera'];        // "Nikon D850"
print_r($data['geolocation']); // ['lat' => ..., 'lng' => ...]
```

---

API Details
-----------

[](#api-details)

### `read(string $filePath, array $options = []): array`

[](#readstring-filepath-array-options---array)

OptionTypeDefaultDescription`fields`int`FIELDS_EXPOSURE`Which EXIF groups to return.`format`int`FORMAT_RAW`Formatting style for exposure values.`keep_raw_keys`boolfalseKeep full, untouched EXIF keys in output.### Available field sets

[](#available-field-sets)

ConstantDescription`GetExif::FIELDS_EXPOSURE`focal length, aperture, shutter, ISO`GetExif::FIELDS_BASIC`camera, created, exposure`GetExif::FIELDS_ALL`all EXIF data the library supports### Formatting modes

[](#formatting-modes)

ConstantExampleDescription`FORMAT_RAW``280/10`untouched EXIF`FORMAT_HUMAN``28`, `4.6`, `1/125`readable numbers`FORMAT_HUMAN_WITH_UNITS``28 mm`, `f/4.6`, `1/125 s`photographer-friendly---

Example Output
--------------

[](#example-output)

```
{
  "camera": "Nikon D850",
  "created": "2020-05-26 14:32:18",
  "exposure": {
    "focal_length": {
      "raw": "280/10",
      "value": "28",
      "value_with_unit": "28 mm"
    },
    "aperture": {
      "raw": "46/10",
      "value": "4.6",
      "value_with_unit": "f/4.6"
    },
    "shutter_speed": {
      "raw": "10/1250",
      "value": "1/125",
      "value_with_unit": "1/125 s"
    },
    "iso": 400
  },
  "geolocation": {
    "lat": 47.12345,
    "lng": 19.98765
  }
}
```

---

Error Handling
--------------

[](#error-handling)

The library throws `GetExifException` for:

- file not found / unreadable
- not a JPEG file
- EXIF block missing or corrupted
- invalid EXIF format

All exceptions contain human-readable error messages.

---

Tips
----

[](#tips)

- For large uploads, configure `upload_max_filesize` and `post_max_size`.
- For web apps: consider adding auto-rotation from EXIF Orientation (feature in development).
- Best results when photographing in RAW+JPEG — some camera brands store richer EXIF in JPEG.

---

Contributing
------------

[](#contributing)

Pull requests are welcome. For issues, bug reports or feature suggestions, please open a GitHub Issue.

---

License
-------

[](#license)

This project is released under the **MIT License**. See the `LICENSE` file for full details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance70

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31d2b838c931a2a767f59c72e227e1d4568b8a7f0a4f1e168a7ff799e9d55c7c?d=identicon)[szalayk](/maintainers/szalayk)

---

Top Contributors

[![szalayk](https://avatars.githubusercontent.com/u/50156049?v=4)](https://github.com/szalayk "szalayk (2 commits)")

### Embed Badge

![Health badge](/badges/szalayk-get-exif/health.svg)

```
[![Health](https://phpackages.com/badges/szalayk-get-exif/health.svg)](https://phpackages.com/packages/szalayk-get-exif)
```

###  Alternatives

[ccinn/husky-php

Similar to js-husky client git hook implementation

6827.0k1](/packages/ccinn-husky-php)[keios/moneyright

Precise, GAAP-compliant, database-friendly Money Value Object

2055.5k1](/packages/keios-moneyright)[lloricode/laravel-html-table

Html table generator for laravel

1561.9k1](/packages/lloricode-laravel-html-table)[lingxi/hashids

A Hashids bridge for Laravel

183.3k](/packages/lingxi-hashids)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
