Despite the fact that this is an old topic, for me it came out of nowhere with the new php 7.2: Error # 75785 Many errors from exif_read_data
I agree with @maraspin, since any error for any reason and does not deal with it, means poor performance (time, functions).
My goal : get the "DateTimeOriginal" of the uploaded image (not just the create_date file from the tmp file - DateTime).
1. Normal use of exif_read_data:
$exif = exif_read_data(tmp/phpTBAlvX); or $exif = exif_read_data($file->tempName, 'ANY_TAG'); or $exif = exif_read_data($file->tempName, 'IFD0'); or $exif = exif_read_data($file->tempName, 'EXIF');
PHP Warning - yii \ base \ ErrorException exif_read_data (tmp / phpTBAlvX): Process tag (x010D = DocumentNam): Illegal components (0)
2. Use the @ operator to hide the warning:
$exif = @exif_read_data(tmp/phpTBAlvX);
RESULT: $ exif as an array with 20 arguments, but it does not have 'DateTimeOriginal'
Array ( [FileName] => phphT9mZy [FileDateTime] => 1529171254 ... [SectionsFound] => ANY_TAG, IFD0, EXIF [COMPUTED] => Array ( [html] => width="3968" height="2976" [Height] => 2976 [Width] => 3968 ... ) [ImageWidth] => 3968 [ImageLength] => 2976 [BitsPerSample] => Array() [ImageDescription] => cof [Make] => HUAWEI ... [DateTime] => 2018:06:14 12:00:38 [YCbCrPositioning] => 1 )
3. End of decision:
$img = new \Imagick(tmp/phpTBAlvX); $allProp = $img->getImageProperties(); $exifProp = $img->getImageProperties("exif:*");
RESULT: $ allProp as an array with 70 arguments with 'DateTimeOriginal'
Array ( [date:create] => 2018-06-16T21:15:24+03:00 [date:modify] => 2018-06-16T21:15:24+03:00 [exif:ApertureValue] => 227/100 [exif:BitsPerSample] => 8, 8, 8 ... [exif:DateTimeOriginal] => 2018:06:14 12:00:38 [jpeg:colorspace] => 2 [jpeg:sampling-factor] => 2x2,1x1,1x1 )
RESULT: $ exifProp as an array with 66 arguments with 'DateTimeOriginal'
Array ( [exif:ApertureValue] => 227/100 [exif:BitsPerSample] => 8, 8, 8 ... [exif:DateTimeOriginal] => 2018:06:14 12:00:38 )
MY DECISION:
- never use @ to suppress any warning or code
- use the Imagick class to get any image tag