Download the PHP package diderich/metadata without Composer

On this page you can find all versions of the php package diderich/metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package metadata

Latest Stable Version Minimum PHP version License: MIT Standard PHP Innovation Award

Name

Metadata - A PHP class for reading and writing Photo Metadata from JPEG files in a transparent way

Version

See CHANGELOG.md and php constant \Holiday\Metadata::VERSION for the latest version number.

Awards

PHP Innovation Award

Description

The Metadata class and its sub-classes implement transparent read and write access to IPTC Photo Metadata based on the IPTC Photo Metadata Standard 2021.1 and read access to EXIF data from JPEG files, focusing on those metadata elements that are relevant for searching and managing photos within a photo database or similar application. The class is unique in the sense that it supports multiple concurrent languages for the caption/description information.

There exist many implementations for reading and/or writing metadata from photos of various formats. Typically, these packages and programs (exiftool being the most prominent one) focus on decoding raw data in the context of its origin, e.g., decoding EXIF data or decoding IPTC/APP13 data. This project takes a different approach! It takes a user-centric approach and exposes IPTC and EXIF photo metadata in a transparent way to the user, i.e, the user does not have to worry where the data is coming from and/or how it is encoded.

The package has been developed in the context of the proprietary HOLIDAY photo database software (see https://www.cdsp.photo/technology/holiday-database/) as the end-user. As such it may lack functionality relevant for different uses. This explains also the use of the top-level namespace prefix \Holiday.

The decoding and encoding of the JPEG image file into different header segments as well as the decoding and encoding of the IPTC data is inspired in part by The PHP JPEG Metadata Toolkit (https://www.ozhiker.com/electronics/pjmt/), which is hereby duly acknowledged.

Transparent access to JPEG image metadata

The class \Holiday\Metadata allows reading and writing the most relevant (from the author's perspective) photo metadata in JPEG files and access them in a transparent way, independent of where/how they are stored. Data for a field FIELD_ID can be read from file FILENAME using the following code. If no data is found, $data will be equal to false, otherwise it will contain the data read, which may be a string, an integer, or an array:

Data in field FIELD_ID can be updated to NEW_DATA and written back to the same file or a new different file NEW_FILENAME using the code:

The file NEW_FILENAME is automatically overwritten.

Pasting the editable part of the metadata from one file FILENAME to another one named PASTE_FILENAME (which must exist), can be done using the following code:

The caption/description field \Holiday\Metadata::CAPTION supports multiple languages, the default language being named according to the standard) \Holiday\Metadata::LANG_DEFAULT. Access the field's data is done using the following code:

The metadata is read in the following order, the first data read taking priority, i.e, if the CAPTION data is stored in the IPTC/APP13 segment as well as in the XMP/APP1 and EXIF/APP1 segment, the data from the IPTC/APP13 will prevail.

  1. Data found in the IPTC/APP13 segment
  2. Data found the XMP/APP1 segment
  3. Data found in the EXIF/APP1 segment

When writing the metadata back, both IPTC/APP13 and XMP/APP1 fields will be updated to ensure consistency of the data. In the current implementation, user modifiable data stored in the EXIF/APP1 segment is cleared, i.e., replaced by 0x00, rather than updated to the actual value. This choice is due to a) the opinion that EXIF/APP1 should not contain user-editable data and b) the complexity of the EXIF/APP1 data format.

Exception handling

All functions return falsein case of non-fatal errors. Fatal errors trigger the exception \Holiday\Metadata\Exception to be thrown (which extends the generic Exception class). The numerical code associated with an error ($exception->getCode()) allows identifying the type of the error. Constants are defined in the exception class \Holiday\Metadata\Exception.

The function \Holiday\Metadata\Exception::getData()returns additional data relevant to the thrown exception in human readable form.

All exception messages are translatable using the gettext library. A translation template is provided in the locale directory.

Example

The following example shows how to read, modify, and write metadata from JPEG files in a transparent way (see also test/example.php). Is requires/assumes a PSR-4 compliant mechanism for loading the class files.

File and directory structure

The directory structure shown describes the most relevant directories and files of the library.

All class files are commended in a phpDocumenter (https://www.phpdoc.org/) compliant way.

Installation

The metadata class can be installed using composer

Testing

The classes have been successfully tested on a number of JPEG images written by a non-exhaustive list of different camera models. As decoding data is highly dependent on the choices made when encoding the data, the class may be unable to decode some less common JPEG file encodings. This is especially the case for data stored (in a less compliant way) using th XMP format.

No exhaustive test concept for the classes exists and/or is planned.

If you find a JPEG file that is not correctly decoded, please raise an issue in the Issue section AND include a copy of the JPEG file. Issus without accompanying JPEG data will be closed by the author without consideration.

Open issues

The following limitations currently exist and are acknowledged as such:

Important note

Files containing caption/description data in more than one language may not be correctly read/saved by most (it not all) photo editing software, like Photoshop. To the author's knowledge, no of-the-shelve software currently supports multiple concurrent languages, as described by the XMP Specification (referenced as Lang Alt). See https://iptc.org/standards/photo-metadata/interoperability-tests/ for more details about interoperability.

Support

Free community support is available on github.com using the Issues and Discussion sections. The author may participate in providing free support, but does not guarantee to do so. Guaranteed paid support is available from the author.

Project status and road-map

The project is actively maintained. Not new features are currently planned.

Author

Claude Diderich ([email protected]), https://www.cdsp.photo. The author will respond to e-mails at his own discretion.

License

MIT https://opensource.org/licenses/mit


All versions of metadata with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-dom Version *
ext-xml Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package diderich/metadata contains the following files

Loading the files please wait ....