Current Location: Home> Function Categories> read_exif_data

read_exif_data

Alias ​​exif_read_data
Name:read_exif_data
Category:Exif exchangeable image information
Programming Language:php
One-line Description:Read the EXIF ​​header from the image file and is an alternative function to exif_read_data()

Function name: read_exif_data()

Applicable version: PHP 4 >= 4.2.0, PHP 5, PHP 7

Usage: read_exif_data(string $filename, string $sections = NULL, bool $arrays = false, bool $thumbnail = false) : array|false

parameter:

  • $filename (required): The path to the image file to be read.
  • $sections (optional): A specific part of the EXIF ​​data to be read. Can be a string or a comma-separated list of strings. The default is NULL, which means that all parts are read.
  • $arrays (optional): Specifies whether to convert multiple tokens of values ​​into an array. Default is false.
  • $thumbnail (optional): Specifies whether to read the thumbnail of the image. Default is false.

Return value:

  • If the EXIF ​​data is successfully read, a associative array containing the EXIF ​​data is returned. If EXIF ​​data is not found or read failed, false is returned.

Example: <?php $filename = "path/to/image.jpg";

// Read all EXIF ​​data $exifData = read_exif_data($filename); if ($exifData !== false) { echo "EXIF data:"; print_r($exifData); } else { echo "Unable to read EXIF ​​data."; }

// Only read EXIF ​​data for a specific part $sections = "FILE,COMPUTED"; $exifData = read_exif_data($filename, $sections); if ($exifData !== false) { echo "EXIF data for a specified part: "; print_r($exifData); } else { echo "Unable to read EXIF ​​data for a specified part."; }

// Convert multiple values ​​to array$exifData = read_exif_data($filename, NULL, true); if ($exifData !== false) { echo "EXIF data (multiple values ​​are converted to array): "; print_r($exifData); } else { echo "Unable to read EXIF ​​data."; }

// Read the thumbnail of the image $exifData = read_exif_data($filename, NULL, false, true); if ($exifData !== false) { echo "Thumbnail data of the image: "; print_r($exifData); } else { echo "Thumbnail data of the image cannot be read."; } ?>

Similar Functions
Popular Articles