easygithdev/imgmeta
Composer 安装命令:
composer require easygithdev/imgmeta
包简介
Wrapper to access Exif and IPTC data from an image
关键字:
README 文档
README
Wrapper to access Exif and IPTC data from an image.
Installing
Installation is quite typical - with composer:
composer require easygithdev/imgmeta
How to use
Include the autoload, if you need.
<?php
require 'vendor/autoload.php';
use ImgMeta\ImgData;
Define a stream. The stream is a file, a base64 string or an Url :
$stream = 'image.jpg';
$stream = 'data:image/jpeg;base64,iVBOR....';
$stream = 'http://domain/image.jpg';
Accessing to all the metas like this :
$imgData = new ImgData();
$metas = $imgData->read($stream)->getMetas();
Fetching the EXIF or IPTC tags :
$imgData->read($stream)->getExif()->fetch(ExifTags::Copyright);
$imgData->read($stream)->getIptc()->fetch(IptcTags::City);
Or you can use the quick acces :
(new ImgData())->read($stream)->exif('Copyright');
(new ImgData())->read($stream)->iptc('City');
Working with EXIF only
Get all the datas :
$imgData = new ImgData();
$exifManager = $imgData->createExifManager();
$exifManager->read(ExifReader::getReader($stream));
$exifManager->getMetas();
Fetch one tag :
$exifManager->fetch(ExifTags::Copyright);
Or :
$exifManager->fetch('Copyright');
For example to fetch the GPS informations :
$latitude = $exifManager->fetch('GPSLatitude');
$longitude = $exifManager->fetch('GPSLongitude');
Using helper to get the GPS infos :
$exifManager->getPosition();
Working with IPTC only
$imgData = new ImgData();
$iptcManager = $imgData->createIptcManager();
$iptcManager->read(IptcReader::getReader($stream));
Get IPTC default format :
$iptcManager->getMetas();
Get IPTC by Key :
$iptcManager->getMetasByKey();
Get IPTC by Name :
$iptcManager->getMetasByName();
Get IPTC by name with all keys :
$iptcManager->getAssocMetas(IptcManager::META_BY_NAME, true);
Fetch one tag, datas are flatten :
$iptcManager->fetch(IptcTags::Country_PrimaryLocationName);
Fetch one tag, datas are originals :
$iptcManager->fetchAll(IptcTags::Country_PrimaryLocationName);
License
This project is licensed under GNU license - see the LICENSE file for deta
统计信息
- 总下载量: 75
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-06-07