I had some trouble where any photo geo tagged with Picassa was throwing the following error :

Warning: exif_read_data(filename.jpg) [function.exif-read-data]: Error reading from file: got=x2D84(=11652) != itemlen-2=x3340(=13120) in geocoder_exif() (line 25 of /pathtosite/sites/all/modules/contrib/geocoder/plugins/geocoder_handler/exif.inc).
Warning: exif_read_data(filename.jpg) [function.exif-read-data]: Invalid JPEG file in geocoder_exif() (line 25 of /pathtosite/sites/all/modules/contrib/geocoder/plugins/geocoder_handler/exif.inc).

I did a bit of debugging and found that exif_read_data() is having the uri passed into it. I tried changing this to the url instead and this seems to resolve the issue. I have no idea why that would be the case, but it seems to work.

I used the file_create_url() function to convert the uri to a url at line 25 of exif.inc:

<?php if ($data = exif_read_data($url)) { ?>
becomes
<?php if ($data = exif_read_data(file_create_url($url))) { ?>

CommentFileSizeAuthor
#19 1890624-19.patch1.27 KBgifad
#16 1890624-16.diff693 bytesflorisg
#3 1890624.patch694 bytesbalagan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Exploratus’s picture

I was having the exact same problem for a while. Thank u so much! This worked great!

Some images were working, others were not. it seemed so random. Now it all works!

balagan’s picture

Thanks man, you saved my day!

balagan’s picture

Status: Active » Needs review
FileSize
694 bytes

Here is a patch with iancawthorne's solution.

Simon Georges’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

file_create_url() does create a web accessible URL and the documentation for exif_read_data() states that This cannot be an URL., so I find that strange... But the patch applies cleanly on -dev version.

nurulshakina’s picture

Issue summary: View changes

thank you for the patch :)

Simon Georges’s picture

Status: Needs review » Reviewed & tested by the community

I guess it counts as enough reviews.

eleuthere’s picture

Issue tags: +exif, +gps, +format

Hi,
Geocoder exif plugins seems to read GPS data only when it is written in a certain format.
While geocoder works fine with :
Equipment Make: SAMSUNG
Camera Model: GT-I9000
Camera Software: fw 15.16 prm 08.06
(...)
Latitude: N 44� 48' 9
Longitude: E 1� 37' 10
Altitude: 313.99 m

I recently had a trouble with a photo where coordinates were recorded as :

Equipment Make: SAMSUNG
Camera Model: GT-N7000
Camera Software: N7000XXLT5
(...)
Latitude: N 44.8662001� 0'
Longitude: E 2.3135504� 0'
Altitude: 81.28 m

A special mention for GPS Camera Free application that stores coordinates in the file name and nowhere else, like
44722832_2238793_1383840808262.jpg

I discovered this with exiftags, as exiv2 doesn't display GPS infos ans exiftool displays them all in the same format.

I'm quite new to Drupal, trying to build a site, but I once was a php developper. if I can help, tell me.

Simon Georges’s picture

@eluthere, did you test with or without the patch? Do you confirm the patch is working?

eleuthere’s picture

I use Drupal 7.31 / Commons (commons-7.x-3.17)
I rebuilt my site entirely this summer. I suppose the 2 years old patch is included.

I just tested with a few photos.
- Two native photo taken with a GT I9000 passed the test (2013-01-20 10.56.07.jpg, 1,6Mb and 2014-03-23 15.17.48.jpg), even if 2013-01-20 10.56.07.jpg had no recorded coordinate.
- A photo taken with a GT-N7000 and reduced in size with Gimp passed the test. (20140731_115356-s.jpg)
Its original is 2,5Mb, over the 2Mb limit.
- A 1Mb photo taken with a GT-N7000 caused an error:
" Warning: exif_read_data(20140831_153454.jpg): Error reading from file: got=x3FFA(=16378) != itemlen-2=x90DA(=37082) in geocoder_exif() (line 25 of /home/patrick/art4/sites/all/modules/geocoder/plugins/geocoder_handler/exif.inc).
Warning: exif_read_data(20140831_153454.jpg): Invalid JPEG file in geocoder_exif() (line 25 of /home/patrick/art4/sites/all/modules/geocoder/plugins/geocoder_handler/exif.inc)."
It did not provide its coordinates wheraes exiftags says :
"Latitude: N 48.8232863� 0'
Longitude: E 2.3548576� 0'
Altitude: 110.91 m"

When I tried to remove it as the forum icon, I had another error:
"Exception: Invalid GeoJSON: GeometryCollection with no component geometries in GeoJSON->objToGeometryCollection() (line 104 of /home/patrick/art4/sites/all/modules/geophp/geoPHP/lib/adapters/GeoJSON.class.php).
The website encountered an unexpected error. Please try again later. "

- A 125ko photo taken with a GT-N7000 passed the test (20140928_160239.jpg)

I noted their names in order to be able to send them to you if necessary.
Telle me what you think

Simon Georges’s picture

@eleuthere, the patch has not been committed yet. Could you eventually test with it? It it's ok for you too, I think I'll commit it.

eleuthere’s picture

I applied the patch on the /sites/all/modules/geocoder directory
Then I made dopies of my previous photos.
I could create groups. They were correctly located without error messages.
I did not check if I could remove or change the images, nor anything else.
Thanks.
I stay available for more if necessary.

Simon Georges’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -exif, -gps, -format

I went with it. Thanks everybody for the patch and the feedback!

Status: Fixed » Closed (fixed)

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

JGReidy’s picture

Thanks. This patch worked perfectly for me with photos geo-referenced using JetPhoto Studio.

florisg’s picture

FileSize
693 bytes

Please Update this patch according to php specification:
http://php.net/manual/en/function.exif-read-data.php

Parameters
filename :The name of the image file being read. This cannot be an URL.

So line 25 becomes:
if ($data = exif_read_data(drupal_realpath($url))) {

valentin schmid’s picture

Status: Closed (fixed) » Needs review

Patch #3 does not work with private files.

Please use the patch from #16. This one is also more efficient.

Thanks for the patch.

Simon Georges’s picture

Can I have one more review before committing it, to be sure not to make any regression this time?

gifad’s picture

FileSize
1.27 KB

#16 works fine, but I renamed the $url argument to $uri, which represents it better...

  • Simon Georges committed 2ffd3fa on 7.x-1.x authored by gifad
    Issue #1890624 by idevit, gifad: Some images with exif data not reading...
Simon Georges’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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