server icon indicating copy to clipboard operation
server copied to clipboard

Extract GPS data from EXIF

Open artonge opened this issue 2 years ago • 4 comments

I had to do a workaround to read EXIF data properly:

Some work has been done by @CarlSchwan here.

But the exif_read_data call does not work, and probably never worked. One possible explanation is that the resource is wrapped. From the README:

Note: due to php's internal stream buffering the $count passed to the read callback will be equal to php's internal buffer size (8192 on default) an not the number of bytes requested by fopen()

As it works when the stream is not wrapped, it might be an explanation for why the exif_read_data call fails.

To make it work, I copy the stream into a tmp stream without wrappers before passing it to exif_read_data.

artonge avatar Aug 11 '22 17:08 artonge

Just adding my two cents, but the recent changes by @CarlSchwan also made the size property from the EXIF metadata available as a DAV property (see here). Wouldn't it be useful to expose the GPS coordinates to the WebDAV PROPFIND as well? @CarlSchwan @icewind1991

felhe avatar Aug 25 '22 15:08 felhe

Just adding my two cents, but the recent changes by @CarlSchwan also made the size property from the EXIF metadata available as a DAV property (see here). Wouldn't it be useful to expose the GPS coordinates to the WebDAV PROPFIND as well? @CarlSchwan @icewind1991

that's the plan already, it should be automatically exposed once it exists in the database

PVince81 avatar Aug 25 '22 21:08 PVince81

/rebase

PVince81 avatar Sep 16 '22 13:09 PVince81

need to be retested / redone with the old way because now the exif extration is supposed to work as @icewind1991 said the fix for fseek was in https://github.com/nextcloud/server/pull/33718

PVince81 avatar Sep 16 '22 13:09 PVince81

Done and working as expected. I also cherry-picked @CarlSchwan PR that adds a CLI command to extract metadata https://github.com/nextcloud/server/pull/32309

artonge avatar Sep 30 '22 13:09 artonge

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

github-actions[bot] avatar Oct 04 '22 13:10 github-actions[bot]

/backport to stable25

artonge avatar Oct 10 '22 13:10 artonge

@icewind1991, @PVince81, @come-nc, please review :)

artonge avatar Oct 10 '22 13:10 artonge

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

github-actions[bot] avatar Oct 10 '22 16:10 github-actions[bot]

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

github-actions[bot] avatar Oct 10 '22 18:10 github-actions[bot]

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

github-actions[bot] avatar Oct 10 '22 18:10 github-actions[bot]

@artonge please also make sure the new CLI args are present in the documentation

PVince81 avatar Oct 11 '22 09:10 PVince81

We want to use this on iOS and Android clients to fetch location data without downloading the full res image + exif. To me it looks like this code only does the process of obtaining the info but we can't request it from client. Is this added somewhere else?

mpivchev avatar Aug 02 '23 10:08 mpivchev