PHPExif is a library which gives you easy access to the EXIF meta-data of an image

Related tags

Imagery php-exif
Overview

PHPExif v0.6.4 Build Status Coverage Status Code Climate

PHPExif is a library which gives you easy access to the EXIF meta-data of an image.

PHPExif serves as a wrapper around some native or CLI tools which access this EXIF meta-data from an image. As such, it provides a standard API for retrieving and accessing that information.

Supported tools

  • Native PHP functionality (exif_read_data, iptcparse)
  • Exiftool adapter (wrapper for the exiftool binary)

Installation (composer)

composer require miljar/php-exif

Usage

Before v0.3.0

v0.3.0+

Contributing

Please submit all pull requests against the correct branch. The release branch for the next version is a branch with the same name as the next version. Bugfixes should go in the master branch, unless they are for code in a new release branch.

PHPExif is written according the PSR-0/1/2 standards. When submitting code, please make sure it is conform these standards. We aim to have all functionality covered by unit tests. When submitting code, you are strongly encouraged to unit test your code and to keep the level of code coverage on par with the current level.

All contributions are welcomed and greatly appreciated.

Feedback

Have a bug or a feature request? Please open a new issue. Before opening any issue, please search for existing issues.

Contributors

License

MIT License

Comments
  • UTF-8 checking and encoding param support for exiftool

    UTF-8 checking and encoding param support for exiftool

    It seems like I f**ked up my last commit big time. I checked it against a couple other images and unfortunately it re-encoded some IPTC data that was already encoded as UTF-8. So I built in a more intelligent exception handling, and just to be sure, I added a RuntimeException just in case anybody runs into the same problem as I did. I'm attaching a couple of images for testing.

    europress-getty1 exif mti1

    These cases should cover it. One gives a pure ASCII output, the other gives a valid and json_decodeable UTF-8 output, and one gives some kind of Unicode or I don't know output that has to be utf8_encoded just to be sure. The mb_check_encoding method leaves the ASCII and the UTF-8 alone and only bothers with the more "exotic" strings.

    opened by FrivalszkyP 14
  • Geolocation

    Geolocation

    Need

    Geolocation of images, read GPS coordinates from exif gps data

    Solution

    Both native and exiftool adapters mapData methods have been updated to extract GPS coordinates from exif data

    There is no point on having GPS coordinates manipulation on a library which purpose is exif data extraction so I've normalize them to Decimal Degrees format and created juliangut/gps for this coordinates manipulation

    Additionally

    Found an unused variable in getIptcData method on native adapter

    sorry for the spaces removed on empty lines, editor config

    opened by juliangut 8
  • Update unit tests in preparation for PHP 7.2 compatibility

    Update unit tests in preparation for PHP 7.2 compatibility

    This MR modernises the unit tests so they no longer use the deprecated getMock method. This paves the way for PHPUnit to be upgraded, something that's very much needed for enabling PHP 7.2 CI support.

    opened by martin-georgiev 6
  • Use floatval() instead of intval() to avoid improper coord values

    Use floatval() instead of intval() to avoid improper coord values

    On my php 7.2 machine exif coord values for latitude and longitude were rounded to improper values.

    Correct: 52.268676666667,10.510951666667 Wrong: 52.266666666667,10,5

    I changed intval() to floatval() in both mappers and all values are computed as excepted.

    opened by maltehuebner 5
  • Bugfix for fatal error in extractGPSCoordinate

    Bugfix for fatal error in extractGPSCoordinate

    Added a (real world) test image that causes an error in Mapper\Native::extractGPSCoordinate because the value passed to this function is a string instead of an array. Added a fix for this error.

    opened by wasinger 4
  • Failed to extract the copyright message with © symbol

    Failed to extract the copyright message with © symbol

    When a photo-metadata field contains a non-UTF-8 character or character (such as the Windows-1252 copyright symbol [hex 00A9]) in the Copyright field then it's failing silently.

    Bug 
    opened by anbarasan1985 4
  • Exiftool adapter: add -n switch to exiftool call?

    Exiftool adapter: add -n switch to exiftool call?

    Just created a fork to add support for the "Orientation" tag and since all phpunit test were passing I was about to create a PR, but...

    When testing it on a real image I noticed that the native adapter gives an orientation value of 6 while the exiftool adapter returns "Rotate 90 CW". It can be seen on many more tags that exiftool reports human readable values by default where exif_read_data returns a raw numeric value.

    To unify this behavior, there are two options:

    1. Add "-n" to the exiftool call in exiftool adapter. Exiftool will then return raw numeric values as exif_read_data does.
    2. Keep exiftool in "human readable" mode and modify the native adapter so that it converts all raw values to human readable values in the same way as Exiftool does.

    What way would you prefer? It's a question about what kind of data the user expects to be in the Exif object...

    Christoph

    opened by wasinger 4
  • Save attributes

    Save attributes

    Hi, If I set an exif attribute like setOrientation(), how do I save these changes because I realized just calling the setters doesn't actually persist the changes. So what I want is to be able to save these new attributes to the file or a new file.

    opened by ultrasamad 3
  • Add extension requirement to composer.json

    Add extension requirement to composer.json

    Ran into this issue: PHP Fatal error: Uncaught Error: Call to undefined function PHPExif\Adapter\exif_read_data() in /var/www/html/vendor/miljar/php-exif/lib/PHPExif/Adapter/Native.php:182

    I think you can specify the exif extension requirement by adding ext-exif to the require object in composer.json.

    Enhancement Easy pick 
    opened by chrissound 3
  • Fixed normalization of zero degrees coordinates

    Fixed normalization of zero degrees coordinates

    The native mapper will throw up an error – "Division by zero" – if one or both of the coordinates (Latitude/Longitude) are set to 0 (which is valid).

    Also added checks for "GPSLatitudeRef" and "GPSLongitudeRef" tags.

    opened by bonzai 3
  • [proposal] add special method for non-string fields

    [proposal] add special method for non-string fields

    add special method for non-string fields value of some field can be represented as integer value or non-scalar one.

    For example color space field has integer value which i believe can converted into its string code sRGB or something else

    so for that kind of fields we can add pair of additional methods

    function getColorSpaceAsString() { /** */ }
    function setColorSpaceAsString($colorSpace = null) { /** */ }
    
    Enhancement Proposal 
    opened by hanovruslan 3
  • Without Composer

    Without Composer

    Use php-exif without composer thus:

    <?php
    // Ref: https://github.com/PHPExif/php-exif
    // Ref: https://github.com/LycheeOrg/php-exif supports video and altitude too
    
    $path_to_exiflib = '../../libraries/PHPExif/';
    require_once($path_to_exiflib.'Adapter/AdapterInterface.php');
    require_once($path_to_exiflib.'Adapter/AdapterAbstract.php');
    require_once($path_to_exiflib.'Adapter/Exiftool.php');
    require_once($path_to_exiflib.'Adapter/Native.php');
    require_once($path_to_exiflib.'Adapter/NoAdapterException.php');
    require_once($path_to_exiflib.'Hydrator/HydratorInterface.php');
    require_once($path_to_exiflib.'Hydrator/Mutator.php');
    require_once($path_to_exiflib.'Mapper/MapperInterface.php');
    require_once($path_to_exiflib.'Mapper/Exiftool.php');
    require_once($path_to_exiflib.'Mapper/Native.php');
    require_once($path_to_exiflib.'Reader/ReaderInterface.php');
    require_once($path_to_exiflib.'Reader/Reader.php');
    require_once($path_to_exiflib.'Exif.php');
    
    $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Reader\Reader::TYPE_NATIVE);
    $exif = $reader->read('./test.jpg');
    
    echo 'GPS: ' . $exif->getGPS() . PHP_EOL;
    // 13.054053400000001,80.257204999722219
    // https://www.google.com/maps/@13.0540534,80.257205,15z
    // 15z is the zoom out factor
    

    Get sample images with GPS data for testing from: https://github.com/ianare/exif-samples

    GPS and other meta tags are also available in videos and so is the Altitude parameter - all these are enabled in the the following fork: https://github.com/LycheeOrg/php-exif

    Here is an article on Meta Data Extraction: https://www.hackingarticles.in/exiftool-a-meta-data-extractor/

    Extract Exif Data to a CSV file using the tool from: http://www.br-software.com/extracter.html

    Extractor_UI

    sample_output

    opened by apmuthu 0
  • Given path () to the exiftool binary is invalid

    Given path () to the exiftool binary is invalid

    it works with the native adapter but when I change the adapter to Exiftool adapter it throw this error: Given path () to the exiftool binary is invalid

    opened by mohamed-alashry 3
  • Add FFmpeg adapter, fix travis and add fields

    Add FFmpeg adapter, fix travis and add fields

    1. Use FFmpeg/FFprobe as new adapter for Videos Similarly to exiftool, FFmpeg/FFprobe can be used to extract metadata from videos.

    2. Add additional fields for extraction:

    • Altitude
    • Image Direction
    • Make
    • Lens
    • Content Identifier
    • Micro Video Offset
    • Various Quicktime meta data fields
    • Duration (for videos)
    • Framerate (for videos)
    • City, Sublocation, State and Country
      • some more

    3. Fix TravisCI and Update requirement

    • Tests using PHP5.X and PHPv7.0 and PHPv7.1 has been removed - all versions are not supported any more
    • Added testing for PHPv7.4Snaphshot
    • Updated required versions for composer packages (PHPv7.1 or higher needed)
    opened by tmp-hallenser 0
  • WhiteBalance

    WhiteBalance

    Why can't I access whitebalance from a exif attribute ?

    I can see this info when I upload online my picture

    Did I miss-used your library ? (I did var-dumped the whole exif thing but I can't find anything about white balance.

    Thanks.

    opened by antoine-nedelec 1
  • CreateDate tag date format

    CreateDate tag date format

    I'm using your script with Exiftool adapter and I'm getting a fatal error in PHPExif\Exif.php on line 698 (public function setCreationDate(\DateTime $value)) since bool is passed to a function and it's type-hinted to receive a DateTime object, but I'm getting this error only for some images. I dig around a bit and I realized that some images had date format of 'Y:m:d H:i:s' and others had 'Y:m:d H:i:sP'. I fixed it by extending a mapper (PHPExif\Mapper\Exiftool) class and skipped CreateDate key if a value is not an instance of DateTime, but maybe it should parse that date regardless of format since it's readable by exiftool so I assume it is a valid value for that tag.

    Bug Enhancement 
    opened by nikolanedic 0
  • Release v1.0

    Release v1.0

    • [x] Create rel/0.x branch for legacy issues
    • [ ] Complete php-exif-exiftool rewrite
    • [ ] Rewrite php-exif code (factories basically)
    • [ ] Update composer.json: suggest php-exif-native and php-exif-exiftool
    • [ ] Write documentation in php-exif-native and php-exif-exiftool repositories + refer to it from here
    • [ ] Implement issue #22
    v1.x 
    opened by Miljar 0
Releases(v0.6.5)
Owner
null
PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

null 264 Dec 4, 2022
Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

NO LONGER MAINTAINED!!! Image Cache v. 1.0.0 Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file,

Erik Nielsen 455 Dec 30, 2022
PEL: PHP Exif Library

PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

null 264 Dec 4, 2022
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
A simple page view counter that store data as text and shows data as a PNG image

Image Counter A simple page view counter that store data as text and shows the counter as a PNG image.

Victor Ribeiro 10 Apr 19, 2022
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image

Laravel ImageUp The qcod/laravel-imageup is a trait which gives you auto upload, resize and crop for image feature with tons of customization. Install

QCode.in 708 Dec 22, 2022
A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Gravatar for Laravel 5.x, 6, 7 and 8 Installation First, pull in the package through Composer via the command line: composer require creativeorange/gr

Creativeorange 477 Dec 1, 2022
This plugin adds a new image style for the Core Image block.

This plugin adds a new image style for the Core Image block. Introduction How to use? Go to Gutenberg Editor and add a image block. e.g. Add new image

Mahesh Waghmare 3 Feb 17, 2022
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022
⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.

⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.

Jonah Lawrence 2k Jan 9, 2023
The image server plugin allows you to add responsive images via config without extra elements

Grav image server plugin adds picture tag with loading, responsive, high density images

catchIT 7 Dec 30, 2022
PHP 5.3 Object Oriented image manipulation library

Imagine Tweet about it using the #php_imagine hashtag. Image manipulation library for PHP 5.3 inspired by Python's PIL and other image libraries. Requ

Bulat Shakirzyanov 4.3k Jan 6, 2023
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation

PHP Thumb NOTICE - This project was recently updated to 2.0 and is PSR-0 compliant and supports Composer integration. Some parts of the documentation

Ian Selby 985 Dec 4, 2022
PHP Image Manipulation

Intervention Image Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and com

null 13k Jan 3, 2023
🌄 Perceptual image hashing for PHP

ImageHash A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions

Jens Segers 1.9k Dec 28, 2022
:racehorse: find the size of an image without downloading the whole file. Supports batch requests.

FasterImage FasterImage finds the dimensions or filetype of a remote image file given its uri by fetching as little as needed, based on the excellent

Will Washburn 58 Nov 30, 2022
Extract colors from an image like a human would do.

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

The League of Extraordinary Packages 1.2k Jan 1, 2023
php-gd based image templates

gdaisy A highly experimental image templating system based on PHP-GD to dynamically generate image banners and covers. Installation 1. Require erikahe

Erika Heidi 67 Nov 22, 2022