Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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))) { ?>
Comment | File | Size | Author |
---|---|---|---|
#19 | 1890624-19.patch | 1.27 KB | gifad |
#16 | 1890624-16.diff | 693 bytes | florisg |
#3 | 1890624.patch | 694 bytes | balagan |
Comments
Comment #1
Exploratus CreditAttribution: Exploratus commentedI 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!
Comment #2
balagan CreditAttribution: balagan commentedThanks man, you saved my day!
Comment #3
balagan CreditAttribution: balagan commentedHere is a patch with iancawthorne's solution.
Comment #4
Simon Georges CreditAttribution: Simon Georges commentedfile_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.Comment #5
nurulshakina CreditAttribution: nurulshakina commentedthank you for the patch :)
Comment #6
Simon Georges CreditAttribution: Simon Georges commentedI guess it counts as enough reviews.
Comment #7
eleuthere CreditAttribution: eleuthere commentedHi,
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.
Comment #8
Simon Georges CreditAttribution: Simon Georges commented@eluthere, did you test with or without the patch? Do you confirm the patch is working?
Comment #9
eleuthere CreditAttribution: eleuthere commentedI 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
Comment #10
Simon Georges CreditAttribution: Simon Georges commented@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.
Comment #11
eleuthere CreditAttribution: eleuthere commentedI 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.
Comment #13
Simon Georges CreditAttribution: Simon Georges commentedI went with it. Thanks everybody for the patch and the feedback!
Comment #15
JGReidy CreditAttribution: JGReidy commentedThanks. This patch worked perfectly for me with photos geo-referenced using JetPhoto Studio.
Comment #16
florisg CreditAttribution: florisg commentedPlease Update this patch according to php specification:
http://php.net/manual/en/function.exif-read-data.php
So line 25 becomes:
if ($data = exif_read_data(drupal_realpath($url))) {
Comment #17
valentin schmid CreditAttribution: valentin schmid commentedPatch #3 does not work with private files.
Please use the patch from #16. This one is also more efficient.
Thanks for the patch.
Comment #18
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedCan I have one more review before committing it, to be sure not to make any regression this time?
Comment #19
gifad CreditAttribution: gifad commented#16 works fine, but I renamed the $url argument to $uri, which represents it better...
Comment #21
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedCommitted, thanks!