I am working to pull some information from JPEGs supplied to my client by a photographer.
When examined under Windows all of the images contain data in a field called Tags:
To do some testing first I made the following script and am iterating over entries in the binary file headers using the code below.
Sometimes I get values for ImageDescription. Often text in Copyright and Author but the Tags content never ever shows up here and it is the capture of that content the client most wants to automate.
Can anyone advise me as to how I can access the Tags field content?
Uploaded copy of file is here.
UPDATE - changed IDF0 to ANY_TAG and added 3rd arg true to exif_read_data() per Tiger-222's response. Also added print_r output at end of post
UPDATE 2 Added requested error_display() and ini_set() calls and also tried exif_read_data() 2nd arg of 0 in place of 'ANY_TAG' per https://php.net/manual/en/function.exif-read-data.php
<?php
ini_set('display_errors', 1);
ini_set('exif.encode_unicode', 'UTF-8'); // To see WINXP values
error_reporting(-1);
$n = (intval($_GET['n'])) ? $_GET['n'] : 99;
echo "ANI_$n.jpg:<br />\n";
$exif = exif_read_data("ANI_$n.jpg", 'ANY_TAG', true);
echo $exif===false ? "No header data found.<br />\n" : "Image contains the following headers:<br><br />\n";
if ($exif) {
foreach ($exif as $key => $section) {
if (is_array($section)) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
} else {
echo "$key: $section<br>\n";
}
}
}
?>
The following is the content dumped by the script for the whooping crane image:
ANI_69.jpg:
Image contains the following headers:
FileName: ANI_69.jpg
FileDateTime: 1428255617
FileSize: 2448245
FileType: 2
MimeType: image/jpeg
SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF
COMPUTED.html: width="1798" height="2697"
COMPUTED.Height: 2697
COMPUTED.Width: 1798
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 0
COMPUTED.Copyright: Photographer name here
COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
ImageWidth: 1798
ImageLength: 2697
BitsPerSample.0: 8
BitsPerSample.1: 8
BitsPerSample.2: 8
PhotometricInterpretation: 2
Orientation: 1
SamplesPerPixel: 3
XResolution: 1000000/10000
YResolution: 1000000/10000
ResolutionUnit: 2
Software: Adobe Photoshop CS6 (Macintosh)
DateTime: 2014:12:28 19:17:36
Artist: Photographer name here
Copyright: Photographer name here
Exif_IFD_Pointer: 316
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 72/1
THUMBNAIL.YResolution: 72/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 554
THUMBNAIL.JPEGInterchangeFormatLength: 3211
ExifVersion: 0230
DateTimeOriginal: 2014:11:03 11:14:27
DateTimeDigitized: 2014:11:03 11:14:27
SubSecTimeOriginal: 76
SubSecTimeDigitized: 76
ColorSpace: 65535
ExifImageWidth: 1798
ExifImageLength: 2697
Here's a dump of $exif from $exif = exif_read_data("ANI_$n.jpg", 'ANY_TAG', true);
Array
(
[FILE] => Array
(
[FileName] => ANI_69.jpg
[FileDateTime] => 1428255617
[FileSize] => 2448245
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
)
[COMPUTED] => Array
(
[html] => width="1798" height="2697"
[Height] => 2697
[Width] => 1798
[IsColor] => 1
[ByteOrderMotorola] => 0
[Copyright] => Digital Roux Photography LLC
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[IFD0] => Array
(
[ImageWidth] => 1798
[ImageLength] => 2697
[BitsPerSample] => Array
(
[0] => 8
[1] => 8
[2] => 8
)
[PhotometricInterpretation] => 2
[Orientation] => 1
[SamplesPerPixel] => 3
[XResolution] => 1000000/10000
[YResolution] => 1000000/10000
[ResolutionUnit] => 2
[Software] => Adobe Photoshop CS6 (Macintosh)
[DateTime] => 2014:12:28 19:17:36
[Artist] => Digital Roux Photography LLC
[Copyright] => Digital Roux Photography LLC
[Exif_IFD_Pointer] => 316
)
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 554
[JPEGInterchangeFormatLength] => 3211
)
[EXIF] => Array
(
[ExifVersion] => 0230
[DateTimeOriginal] => 2014:11:03 11:14:27
[DateTimeDigitized] => 2014:11:03 11:14:27
[SubSecTimeOriginal] => 76
[SubSecTimeDigitized] => 76
[ColorSpace] => 65535
[ExifImageWidth] => 1798
[ExifImageLength] => 2697
)
)