GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - selective-php/image-type: Image type (format) detection for PHP

BranchesTags
Open more actions menu

Latest commit

 

History

140 Commits
140 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
src
src
 
 
tests
tests
 
 
.cs.php
.cs.php
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpcs.xml
phpcs.xml
 
 
phpstan.neon
phpstan.neon
 
 
phpunit.xml
phpunit.xml
 
 

Repository files navigation

selective/image-type

Image type detection library for PHP.

Latest Version on Packagist Software License Build Status Total Downloads

Features

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

Supported formats

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

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

Compound

  • SWF (Small Web Format, Flash)

RAW

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

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

  • PHP 8.2 - 8.5

Installation

composer require selective/image-type

Usage

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

$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

  • https://github.com/exiftool/exiftool
  • https://github.com/willwashburn/fasterimage

License

  • MIT

About

Image type (format) detection for PHP

Topics

imageimage-formatimage-typephp

Resources

Readme
MIT license
Activity
Custom properties

Stars

7 stars

Watchers

3 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.