PHPackages                             joserick/png-metadata - 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. joserick/png-metadata

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

joserick/png-metadata
=====================

A PHP library for extract the metadata (XMP, EXIF) within a PNG format image.

v0.2.8(3y ago)2140.8k↑547%4[1 issues](https://github.com/joserick/PNGMetadata/issues)GPL-3.0PHPPHP ^7.4 || ^8.0CI failing

Since Oct 6Pushed 2y ago3 watchersCompare

[ Source](https://github.com/joserick/PNGMetadata)[ Packagist](https://packagist.org/packages/joserick/png-metadata)[ RSS](/packages/joserick-png-metadata/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (5)Versions (9)Used By (0)

Welcome to PNGMetadata!
=======================

[](#welcome-to-pngmetadata)

PNGMetadata is a library which is able to extract the metadata of an image in png format.

It is important to mention that PNGMetadata does **not** use the software ExifTool so it is completely native.

[![PNGMetadata.gif](https://camo.githubusercontent.com/af5623b8a446a7fd5dc1da8b8d5a15f8d81a046d3595f0eda27420a53dc19135/68747470733a2f2f6a6f73657269636b2e636f6d2f646f63732f706e676d657461646174612f504e474d657461646174612e676966)](https://camo.githubusercontent.com/af5623b8a446a7fd5dc1da8b8d5a15f8d81a046d3595f0eda27420a53dc19135/68747470733a2f2f6a6f73657269636b2e636f6d2f646f63732f706e676d657461646174612f504e474d657461646174612e676966)

Enjoying this package? [!["Buy Me A Coffee"](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/joserick)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#enjoying-this-package-)

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

[](#requirements)

- PHP &gt;= 7.4
- XML PHP Extension
- JSON PHP Extension
- GD PHP Extension
- EXIF PHP Extension

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

[](#installation)

Use the package manager [Composer](https://getcomposer.org/) to install PNGMetadata.

```
$ composer require joserick/png-metadata
```

Use
---

[](#use)

### Getting a PNGMetadata Instance

[](#getting-a-pngmetadata-instance)

```
// include composer autoload
require 'vendor/autoload.php';

// import the Joserick PNGMetadata
use PNGMetadata\PNGMetadata;

// build PNGMetadata object with a image path.
$png_metadata = new PNGMetadata('Photo.png'); // return a 'ArrayObject' or 'Exception'
```

In case you don't want to see any **errors** (Exception) generated you can used the static function '**extract()**' which returns a 'false' in case of error.

```
$png_metadata = PNGMetadata::extract('Photo.png'); // return a 'ArrayObject' or 'False'
```

If you want work with simple array without any other function you can call to '**toArray()**'.

```
$png_metadata = new PNGMetadata('Photo.png');
$metadata_array = $png_metadata->toArray(); // return simple 'Array'
//or
$metadata_array = PNGMetadata::extract('Photo.png')->toArray(); // return simple 'Array'
```

Examples
--------

[](#examples)

### Example 1 - All

[](#example-1---all)

Print all the metadata.

```
$png_metadata = new PNGMetadata('../Photo.png');
echo $png_metadata; // Print metadata in 2 colums.
```

Out:

MetadataValueexif:DateTime2019:09:08 23:01:23exif:MakeSONYexif:MimeTypeimage/png......### Example 2 - Get Metadata

[](#example-2---get-metadata)

Get specific metadata.

```
$png_metadata = new PNGMetadata(___DIR___.'/Photo.png');
echo $png_metadata->get('exif:DateTime'); // Return a value, a array or false.
```

### Example 3 - Types

[](#example-3---types)

Print the metadata types (IHDR, sRGB, BKGD, EXIF, XMP, CRS, DATE, DC, ICC, AUX, ...).

```
$png_metadata = new PNGMetadata('./Path/Photo.png');
// or
$png_metadata = PNGMetadata::extract('./Path/Photo.png');

foreach($png_metadata as $key => $value){
	echo $key . ""; // Metadata types
}
```

Extras Functions
----------------

[](#extras-functions)

### Get the thumbnail stored in the metadata!

[](#get-the-thumbnail-stored-in-the-metadata)

```
$png_metadata = new PNGMetadata('../Photo.png');
// or
$png_metadata = PNGMetadata::extract('../Photo.png');

$thumb = $png_metadata->getThumbnail();

if ($thumb !== false) {
	header('Content-Type: image/png');
	imagepng($thumb);
	imagedestroy($thumb);
}
```

### Is PNG?

[](#is-png)

```
if (PNGMetadata::isPNG('./Photo_jpg.png')){
	echo 'Yes, it is a PNG.';
}else{
	echo 'No, it is not a PNG.'
}
```

### What type?

[](#what-type)

GIF(1)JPEG(2)PNG (3)SWF(4)PSD(5)BMP(6)TIFF\_II(7)TIFF\_MM(8)JP2 (10)JPX(11)JB2(12)SWC(13)IFF(14)WBMP(15)XBM(16)ICO(17)WEBP(18)```
return PNGMetadata::getType('./Photo') == 1 // GIF?

```

License
-------

[](#license)

The GNU Public License (GPLv3). Please see [License File](https://github.com/joserick/PNGMetadata/blob/master/LICENSE) for more information.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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

Every ~194 days

Recently: every ~291 days

Total

7

Last Release

1289d ago

PHP version history (3 changes)v0.1PHP &gt;=5.6

0.2.7PHP &gt;=7.4

v0.2.8PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15143699?v=4)[Jose Erick Carreon](/maintainers/joserick)[@joserick](https://github.com/joserick)

---

Top Contributors

[![joserick](https://avatars.githubusercontent.com/u/15143699?v=4)](https://github.com/joserick "joserick (20 commits)")[![janbarasek](https://avatars.githubusercontent.com/u/4738758?v=4)](https://github.com/janbarasek "janbarasek (12 commits)")[![ericek111](https://avatars.githubusercontent.com/u/7243565?v=4)](https://github.com/ericek111 "ericek111 (2 commits)")[![twistor](https://avatars.githubusercontent.com/u/42400?v=4)](https://github.com/twistor "twistor (1 commits)")

---

Tags

metadatapngexifexiftoolxmp

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/joserick-png-metadata/health.svg)

```
[![Health](https://phpackages.com/badges/joserick-png-metadata/health.svg)](https://phpackages.com/packages/joserick-png-metadata)
```

###  Alternatives

[picqer/php-barcode-generator

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.8k27.4M109](/packages/picqer-php-barcode-generator)[rosell-dk/webp-convert

Convert JPEG &amp; PNG to WebP with PHP

6058.7M59](/packages/rosell-dk-webp-convert)[yzalis/identicon

Generate unique identicon avatars from any string

6091.1M23](/packages/yzalis-identicon)[alchemy/phpexiftool

Exiftool driver for PHP

40190.6k4](/packages/alchemy-phpexiftool)[frameright/image-metadata-parser

Image metadata parsing library

1135.1k](/packages/frameright-image-metadata-parser)[fileeye/pel

PHP Exif Library. A library for reading and writing Exif headers in JPEG and TIFF images using PHP.

207.7M2](/packages/fileeye-pel)

PHPackages © 2026

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