How to install ExifTool with Composer

I’m working on a PHP project, that uses Phil Harveys excellent ExifTool to read Exif and XMP tags from photos. Since ExifTool is written in Perl, there is of course no composer.json to install this dependency directly with Composer. But you can create your own package information in your master composer.json as follows:

{
    ...
    "repositories": [
        ...        
        {
            "type": "package",
            "package": {
                "name": "philharvey/exiftool",
                "version": "10.75",
                "dist": {
                    "url": "https://sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.75.tar.gz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        ...
        "philharvey/exiftool": "10.*"
    }
}

This will automatically download ExifTool version 10.75 and extract it into the vendor folder /vendor/philharvey/exiftool/

Note, that the package type ‘tar’ should extract the file completely. If that is not the case, make sure you have the latest composer version 1.6.2 installed. Some Linux distributions (e.g. Linux Mint 18.3 and probably Ubuntu 16.4 too) are still on version 1.0.0-beta2, which does not support extracting ‘tar.gz’. Read my quick tutorial on how to upgrade composer on Linux Mint 18.3.

 

Leave a Reply

Your email address will not be published. Required fields are marked *