The getExif method currently looks like this:

  protected function getExif($uri) {
    return exif_read_data($uri, 'EXIF');
  }

I'm not sure why, but exif_read_data() always returns false on my local environment (using DrupalVM with PHP 7.2).
When I change $uri to be an actual filepath instead of a streamwrapper, it does work.
I will add a patch.

CommentFileSizeAuthor
#2 3031810-2.patch518 bytesdaluxz

Comments

Daluxz created an issue. See original summary.

daluxz’s picture

Status: Active » Needs review
StatusFileSize
new518 bytes

Here's the patch.

nick hope’s picture

In use with PHP 7.3.15 I was getting many failures with various errors such as

Warning: exif_read_data(): Error reading from file: got=x2330(=9008) != itemlen-2=x39F2(=14834) in Drupal\media_entity_image_exif\Plugin\media\Source\ImageWithExif->getExif() (line 169 of modules\custom\media_entity_image_exif\src\Plugin\media\Source\ImageWithExif.php).

and

Warning: exif_read_data(): Process tag(x0000=UndefinedTa): Illegal format code 0x0000, suppose BYTE in Drupal\media_entity_image_exif\Plugin\media\Source\ImageWithExif->getExif() (line 169 of modules\custom\media_entity_image_exif\src\Plugin\media\Source\ImageWithExif.php).

and

Warning: exif_read_data(): Invalid JPEG file in Drupal\media_entity_image_exif\Plugin\media\Source\ImageWithExif->getExif() (line 169 of modules\custom\media_entity_image_exif\src\Plugin\media\Source\ImageWithExif.php).

(Note that my version of ImageWithExif.php is now very edited, so the line numbers are unique to me)

This patch has made it much more stable for me, with no errors since I started testing it. Thank you.

(For interest, there is some related discussion with reference to the Geocoder module in this issue)

damienmckenna’s picture

I think the errors reported in #3 are unrelated and should be examined separately.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.