PHPackages                             dchesterton/image - 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. [Image &amp; Media](/categories/media)
4. /
5. dchesterton/image

ActiveLibrary[Image &amp; Media](/categories/media)

dchesterton/image
=================

Image metadata library

4138.8k↓22.3%22[2 PRs](https://github.com/dchesterton/image/pulls)PHP

Since Sep 9Pushed 3y ago5 watchersCompare

[ Source](https://github.com/dchesterton/image)[ Packagist](https://packagist.org/packages/dchesterton/image)[ RSS](/packages/dchesterton-image/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Image metadata library (PHP 5.5+)
=================================

[](#image-metadata-library-php-55)

[![Build Status](https://camo.githubusercontent.com/47951cbe9ce20cdbc95c457ae47a4da96d0b98c3fe7003e421fc86b18dd70d34/68747470733a2f2f7472617669732d63692e6f72672f6463686573746572746f6e2f696d6167652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dchesterton/image) [![Dependency Status](https://camo.githubusercontent.com/092d6ece75daa79ee90757163845c3065c1c93f931688a05adde5d45bef3fa5f/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3534393432383362646437303964383131663030303464662f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/5494283bdd709d811f0004df)

[![Latest Stable Version](https://camo.githubusercontent.com/2883f2cf573da551814149f92779a26b67175f7d84c77630800d7a88dac55cbd/68747470733a2f2f706f7365722e707567782e6f72672f6463686573746572746f6e2f696d6167652f762f737461626c652e737667)](https://packagist.org/packages/dchesterton/image) [![Total Downloads](https://camo.githubusercontent.com/d8eb00dbcdfbbb9b70c5d1ff31e20473a1dc0c5d94361e09c5c54cb315af6b3f/68747470733a2f2f706f7365722e707567782e6f72672f6463686573746572746f6e2f696d6167652f646f776e6c6f6164732e737667)](https://packagist.org/packages/dchesterton/image) [![Latest Unstable Version](https://camo.githubusercontent.com/e2c275ab277f0da7360b64a1ec1d4ff91eac7c4385a3d81db8216093d5928527/68747470733a2f2f706f7365722e707567782e6f72672f6463686573746572746f6e2f696d6167652f762f756e737461626c652e737667)](https://packagist.org/packages/dchesterton/image) [![License](https://camo.githubusercontent.com/d404c652b1e1d2c2bf54d24cf042d7e12d1de72963a9678615aefb864e04a5fc/68747470733a2f2f706f7365722e707567782e6f72672f6463686573746572746f6e2f696d6167652f6c6963656e73652e737667)](https://packagist.org/packages/dchesterton/image)

Warning: This library is pre-alpha and much of it is a WIP or simply not working at all. Proceed at your own risk.
------------------------------------------------------------------------------------------------------------------

[](#warning-this-library-is-pre-alpha-and-much-of-it-is-a-wip-or-simply-not-working-at-all-proceed-at-your-own-risk)

Supported image types:

- JPEG
- PNG
- GIF
- PDF
- SVG
- WEBP
- TIFF
- DNG
- RAW FORMATS- CR2, NEF, etc.

Supported image meta types:

- XMP
- IPTC
- EXIF

### Get metadata

[](#get-metadata)

```
$image = Image::fromFile($filename);

$headline = $image->getXmp()->getHeadline();
$camera = $image->getExif()->getCamera();
...
```

### Modify existing metadata

[](#modify-existing-metadata)

```
$image = Image::fromFile($filename);

$xmp = $image->getXmp();
$xmp->setHeadline('A test headline');
$xmp->setCaption('Caption');

$image->getIptc()->setCategory('Category');

$image->save();
```

### Standalone XMP

[](#standalone-xmp)

#### Generating standalone XMP

[](#generating-standalone-xmp)

```
$xmp = new Xmp;
$xmp->setHeadline('A headline')
...

$data = $xmp->getXml();
```

#### Modifying standalone XMP

[](#modifying-standalone-xmp)

```
$xmp = new Xmp($data); // or Xmp::fromFile($filename)
$xmp->setHeadline('A headline');

$data = $xmp->getXml();
```

### Setting/replacing XMP in image

[](#settingreplacing-xmp-in-image)

```
$xmp = new Xmp;
$xmp->setHeadline('A headline');
...

$image = Image::fromFile($filename);
$image->setXmp($xmp);

$image->save() // or $image->getBytes()
```

### Loading specific image type

[](#loading-specific-image-type)

When file type is known, you can load the file type directly using the file types' `fromFile` method.

```
$jpeg = JPEG::fromFile('image.jpg');
$png = PNG::fromFile('image.png');
```

### Instantiate from bytes

[](#instantiate-from-bytes)

If you don't have a file to work with but you do have the image stored in a string (from database, ImageMagick etc.) you can easily instantiate an object from the string.

```
$data = ...

$jpeg = JPEG::fromString($data);
$jpeg->getXmp()->setHeadline('Test headline');

$jpeg->save('out.jpg'); // or $jpeg->getBytes();
```

### Instantiate from GD or a stream

[](#instantiate-from-gd-or-a-stream)

You can also create an object from a GD resource or a stream.

```
$gd = imagecreate(100, 100);
$jpeg = JPEG::fromResource($gd);
```

```
$stream = fopen('...', 'r+');
$jpeg = JPEG::fromStream($stream);
```

### Aggregate metadata

[](#aggregate-metadata)

When just want a piece of metadata and don't care whether it's from XMP, IPTC or EXIF, you can use the aggregate meta object.

```
$image = Image::fromFile($filename);
$headline = $image->getAggregate()->getHeadline();
```

By default it checks XMP first, then IPTC, then EXIF but you can change the priority:

```
$aggregate = $image->getAggregate();
$aggregate->setPriority(['exif', 'iptc', 'xmp']);

$aggregate->getHeadline(); // will now check EXIF first, then IPTC, then XMP
```

You can also exclude a metadata type if you do not want to use it:

```
$aggregate->setPriority(['iptc', 'xmp']);
$aggregate->getHeadline(); // will only check IPTC and XMP
```

You can also modify metadata on an aggregate level:

```
$image = Image::fromFile($filename);
$image->getAggregate()->setHeadline('Headline');

$image->save();
```

This would set the headline in both XMP and IPTC. For maximum compatibility with other software it's recommended to use the aggregate metadata object where available.

#### Get GPS data

[](#get-gps-data)

```
$image = ...
$gps = $image->getAggregateMeta()->getGPS(); // checks EXIF and XMP
// or $gps = $image->getExif()->getGPS();

$lat = $gps->getLatitude();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a5d2eff4c89f7749fc74bd3f1d419251a7081f4429f491469f2c5ca4451cf2d1?d=identicon)[dchesterton](/maintainers/dchesterton)

### Embed Badge

![Health badge](/badges/dchesterton-image/health.svg)

```
[![Health](https://phpackages.com/badges/dchesterton-image/health.svg)](https://phpackages.com/packages/dchesterton-image)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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