PHPackages                             selective/image-type - 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. selective/image-type

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

selective/image-type
====================

Image type detection

1.3.0(2mo ago)7275.1k—5.1%41MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jun 12Pushed 2mo ago3 watchersCompare

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

READMEChangelog (8)Dependencies (8)Versions (9)Used By (1)

selective/image-type
====================

[](#selectiveimage-type)

Image type detection library for PHP.

[![Latest Version on Packagist](https://camo.githubusercontent.com/bc15fea57d7788474674478e53a38206da7e6a159e330005800843f1b61d8719/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73656c6563746976652d7068702f696d6167652d747970652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/selective/image-type)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://github.com/selective-php/image-type/workflows/build/badge.svg)](https://github.com/selective-php/image-type/actions)[![Total Downloads](https://camo.githubusercontent.com/e692dc570cf30ec7bb7898658b9c2d1b92b4e08b0d17f60ff8bc18bee3a4b4b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656c6563746976652f696d6167652d747970652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/selective/image-type/stats)

Features
--------

[](#features)

- Detection of the image type based on its content (header)
- No dependencies
- Very fast

### Supported formats

[](#supported-formats)

#### Raster

[](#raster)

- **ANI** (Animated Cursor)
- **BMP** (Windows Bitmap)
- **CUR** (Cursor)
- **DICOM** (Digital Imaging and Communications in Medicine)
- **GIF** (Graphics Interchange Format)
- **HEIF** / **HEIC** (High Efficiency Image File Format) / Apple iPhone photos
- **ICO** (Icon)
- **JNG** (JPEG Network Graphics)
- **JPEG 2000**
- **JPG** / **JPEG** (Joint Photographic Experts Group)
- **JPM** (JPEG 2000 compound image)
- **MNG** (Multiple-image Network Graphics)
- **PDN** (PaintDotNet)
- **PGM** (Portable Graymap)
- **PNG** (Portable Network Graphics)
- **PPM** (Portable Pixelmap)
- **PSB** (Photoshop Large Document)
- **PSD** (Photoshop Document)
- **TIF** / **TIFF** (Tagged Image File Format)
- **WEBP** (WebP)
- **XCF** (eXperimental Computing Facility (GIMP))

#### Vector

[](#vector)

- **AI** (Adobe Illustrator)
- **EMF** (Enhanced Metafile)
- **EMF+** (Enhanced Metafile)
- **SVG** (Scalable Vector Graphics)
- **WMF** (Windows Metafile Format)

#### Compound

[](#compound)

- **SWF** (Small Web Format, Flash)

#### RAW

[](#raw)

- **3FR** (Hasselblad)
- **CR2** (Cannon)
- **CR3** (Canon)
- **DNG** (Digital Negative - Adobe)
- **IIQ** (Phase One)
- **ORF** (Olympus)
- **PEF** (Pentax)
- **RW2** (Panasonic)

#### HDR

[](#hdr)

- **JPEG-HDR**
- **CIN** (Cineon Image File Format, Kodak)
- **DPX** (Digital Picture Exchange)
- **OpenEXR**
- **PBM** (Portable Bit Map HDR)
- **PFM** (Portable Float Map)
- **Radiance HDR**

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

[](#requirements)

- PHP 8.2 - 8.5

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

[](#installation)

```
composer require selective/image-type

```

Usage
-----

[](#usage)

### Detect the image type of file

[](#detect-the-image-type-of-file)

```
use Selective\ImageType\ImageTypeDetector;
use Selective\ImageType\Provider\RasterProvider;
use Selective\ImageType\Provider\HdrProvider;
use Selective\ImageType\Provider\RawProvider;
use Selective\ImageType\Provider\VectorProvider;
use SplFileObject;

$file = new SplFileObject('example.jpg');

$detector = new ImageTypeDetector();

// Add image detectors
$detector->addProvider(new HdrProvider());
$detector->addProvider(new RawProvider());
$detector->addProvider(new VectorProvider());
$detector->addProvider(new RasterProvider());

$imageType = $detector->getImageTypeFromFile($file);

// Get the image format
echo $imageType->getFormat(); // jpeg

// Get the mime type
echo $imageType->getMimeType(); // image/jpeg
```

### Detect the image type of in-memory object

[](#detect-the-image-type-of-in-memory-object)

```
$image = new SplTempFileObject();

$image->fwrite('my file content');

$detector = new ImageTypeDetector();

// Add image detectors
$detector->addProvider(new RasterProvider());

echo $detector->getImageTypeFromFile($file)->getFormat();
```

Similar libraries
-----------------

[](#similar-libraries)

-
-

License
-------

[](#license)

- MIT

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance84

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 80% 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 ~350 days

Recently: every ~602 days

Total

8

Last Release

80d ago

Major Versions

0.4.0 → 1.0.02019-09-03

PHP version history (5 changes)0.1.0PHP ^7.2

1.0.0PHP ^7.1

1.1.0PHP ^7.2 || ^8.0

1.2.0PHP ^8.1

1.3.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/89d408d7f6ed65cdbeba70a2da2d0a8a1135fc37ebc07c44989f509221cc91bd?d=identicon)[odan](/maintainers/odan)

---

Top Contributors

[![odan](https://avatars.githubusercontent.com/u/781074?v=4)](https://github.com/odan "odan (112 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (23 commits)")[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (3 commits)")[![heinrichschiller](https://avatars.githubusercontent.com/u/25958414?v=4)](https://github.com/heinrichschiller "heinrichschiller (2 commits)")

---

Tags

imageimage-formatimage-typephptypeimageformat

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[intervention/image

PHP Image Processing

14.3k194.3M2.2k](/packages/intervention-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k38.3M217](/packages/liip-imagine-bundle)[spatie/image

Manipulate images with an expressive API

1.4k54.4M138](/packages/spatie-image)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[intervention/gif

PHP GIF Encoder/Decoder

5720.3M9](/packages/intervention-gif)

PHPackages © 2026

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