{"id":20672786,"url":"https://github.com/selective-php/image-type","last_synced_at":"2025-04-19T19:10:46.407Z","repository":{"id":45566454,"uuid":"190987909","full_name":"selective-php/image-type","owner":"selective-php","description":"Image type (format) detection for PHP","archived":false,"fork":false,"pushed_at":"2023-09-09T19:25:06.000Z","size":61781,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-27T21:14:45.857Z","etag":null,"topics":["image","image-format","image-type","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selective-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-09T09:32:28.000Z","updated_at":"2023-08-04T03:54:14.000Z","dependencies_parsed_at":"2022-09-04T13:51:32.528Z","dependency_job_id":null,"html_url":"https://github.com/selective-php/image-type","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fimage-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fimage-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fimage-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fimage-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selective-php","download_url":"https://codeload.github.com/selective-php/image-type/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224970157,"owners_count":17400294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image","image-format","image-type","php"],"created_at":"2024-11-16T20:38:48.257Z","updated_at":"2024-11-16T20:38:48.706Z","avatar_url":"https://github.com/selective-php.png","language":"PHP","readme":"# selective/image-type\n\nImage type detection library for PHP.\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/image-type.svg?style=flat-square)](https://packagist.org/packages/selective/image-type)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://github.com/selective-php/image-type/workflows/build/badge.svg)](https://github.com/selective-php/image-type/actions)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/image-type.svg?style=flat-square)](https://scrutinizer-ci.com/g/selective-php/image-type/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/image-type.svg?style=flat-square)](https://scrutinizer-ci.com/g/selective-php/image-type/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/selective/image-type.svg?style=flat-square)](https://packagist.org/packages/selective/image-type/stats)\n\n\n## Features\n\n* Detection of the image type based on its content (header)\n* No dependencies\n* Very fast\n\n### Supported formats\n\n#### Raster\n\n* **ANI** (Animated Cursor)\n* **BMP** (Windows Bitmap)\n* **CUR** (Cursor)\n* **DICOM** (Digital Imaging and Communications in Medicine)\n* **GIF** (Graphics Interchange Format)\n* **HEIF** / **HEIC** (High Efficiency Image File Format) / Apple iPhone photos\n* **ICO** (Icon)\n* **JNG** (JPEG Network Graphics)\n* **JPEG 2000**\n* **JPG** / **JPEG** (Joint Photographic Experts Group)\n* **JPM** (JPEG 2000 compound image)\n* **MNG** (Multiple-image Network Graphics)\n* **PDN** (PaintDotNet)\n* **PGM** (Portable Graymap)\n* **PNG** (Portable Network Graphics)\n* **PPM** (Portable Pixelmap)\n* **PSB** (Photoshop Large Document)\n* **PSD** (Photoshop Document)\n* **TIF** / **TIFF** (Tagged Image File Format)\n* **WEBP** (WebP)\n* **XCF** (eXperimental Computing Facility (GIMP))\n\n#### Vector\n\n* **AI** (Adobe Illustrator)\n* **EMF** (Enhanced Metafile)\n* **EMF+** (Enhanced Metafile)\n* **SVG** (Scalable Vector Graphics)\n* **WMF** (Windows Metafile Format)\n\n#### Compound\n\n* **SWF** (Small Web Format, Flash)\n\n#### RAW\n\n* **3FR** (Hasselblad)\n* **CR2** (Cannon)\n* **CR3** (Canon)\n* **DNG** (Digital Negative - Adobe)\n* **IIQ** (Phase One)\n* **ORF** (Olympus)\n* **PEF** (Pentax)\n* **RW2** (Panasonic)\n\n#### HDR\n\n* **JPEG-HDR**\n* **CIN** (Cineon Image File Format, Kodak)\n* **DPX** (Digital Picture Exchange)\n* **OpenEXR**\n* **PBM** (Portable Bit Map HDR)\n* **PFM** (Portable Float Map)\n* **Radiance HDR**\n\n## Requirements\n\n* PHP 8.1+\n\n## Installation\n\n```\ncomposer require selective/image-type\n```\n\n## Usage\n\n### Detect the image type of file\n\n```php\nuse Selective\\ImageType\\ImageTypeDetector;\nuse Selective\\ImageType\\Provider\\RasterProvider;\nuse Selective\\ImageType\\Provider\\HdrProvider;\nuse Selective\\ImageType\\Provider\\RawProvider;\nuse Selective\\ImageType\\Provider\\VectorProvider;\nuse SplFileObject;\n\n$file = new SplFileObject('example.jpg');\n\n$detector = new ImageTypeDetector();\n\n// Add image detectors\n$detector-\u003eaddProvider(new HdrProvider());\n$detector-\u003eaddProvider(new RawProvider());\n$detector-\u003eaddProvider(new VectorProvider());\n$detector-\u003eaddProvider(new RasterProvider());\n\n$imageType = $detector-\u003egetImageTypeFromFile($file);\n\n// Get the image format\necho $imageType-\u003egetFormat(); // jpeg\n\n// Get the mime type\necho $imageType-\u003egetMimeType(); // image/jpeg\n```\n\n### Detect the image type of in-memory object\n\n```php\n$image = new SplTempFileObject();\n\n$image-\u003efwrite('my file content');\n\n$detector = new ImageTypeDetector();\n\n// Add image detectors\n$detector-\u003eaddProvider(new RasterProvider());\n\necho $detector-\u003egetImageTypeFromFile($file)-\u003egetFormat();\n```\n\n## Similar libraries\n\n* https://github.com/exiftool/exiftool\n* https://github.com/willwashburn/fasterimage\n\n## License\n\n* MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselective-php%2Fimage-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselective-php%2Fimage-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselective-php%2Fimage-type/lists"}