joserick/png-metadata
Composer 安装命令:
composer require joserick/png-metadata
包简介
A PHP library for extract the metadata (XMP, EXIF) within a PNG format image.
README 文档
README
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.
Enjoying this package? 
Requirements
- PHP >= 7.4
- XML PHP Extension
- JSON PHP Extension
- GD PHP Extension
- EXIF PHP Extension
Installation
Use the package manager Composer to install PNGMetadata.
$ composer require joserick/png-metadata
Use
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
Example 1 - All
Print all the metadata.
$png_metadata = new PNGMetadata('../Photo.png'); echo $png_metadata; // Print metadata in 2 colums.
Out:
| Metadata | Value |
|---|---|
| exif:DateTime | 2019:09:08 23:01:23 |
| exif:Make | SONY |
| exif:MimeType | image/png |
| ... | ... |
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
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 . "<br>"; // Metadata types }
Extras Functions
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?
if (PNGMetadata::isPNG('./Photo_jpg.png')){ echo 'Yes, it is a PNG.'; }else{ echo 'No, it is not a PNG.' }
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
The GNU Public License (GPLv3). Please see License File for more information.
joserick/png-metadata 适用场景与选型建议
joserick/png-metadata 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41.81k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2019 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「metadata」 「exif」 「xmp」 「exiftool」 「png」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 joserick/png-metadata 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joserick/png-metadata 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 joserick/png-metadata 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This extension detects and extracts metadata (EXIF / IPTC / XMP / ...) from potentially thousand different file types (such as MS Word/Powerpoint/Excel documents, PDF and images) and bring them automatically and natively to TYPO3 when uploading assets. Works with built-in PHP functions but takes adv
Extracting XMP metadata from images using PHP.
Object-Oriented EXIF parsing
PHP client library for FilePreviews.io
Image metadata parsing library
Image metadata library
统计信息
- 总下载量: 41.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2019-10-05