Reading Geotag data from image in php

前端 未结 6 940
醉酒成梦
醉酒成梦 2020-12-28 09:25

Does anyone know if there is a way to read geotag data from photos in PHP?

Thanks

6条回答
  •  被撕碎了的回忆
    2020-12-28 09:32

    Install Intervention\Image by following command.

    Reference: http://image.intervention.io/getting_started/installation

    composer require intervention/image

    Update config/app.php

    'providers' => [ Intervention\Image\ImageServiceProvider::class ], 'aliases' => [ 'Image' => Intervention\Image\Facades\Image::class ]

    Use Library:

    $data = Image::make(public_path('IMG.jpg'))->exif(); if(isset($data['GPSLatitude'])) { $lat = eval('return ' . $data['GPSLatitude'][0] . ';') + (eval('return ' . $data['GPSLatitude'][1] . ';') / 60) + (eval('return ' . $data['GPSLatitude'][2] . ';') / 3600); $lng = eval('return ' . $data['GPSLongitude'][0] . ';') + (eval('return ' . $data['GPSLongitude'][1] . ';') / 60) + (eval('return ' . $data['GPSLongitude'][2] . ';') / 3600); echo "$lat, $lng"; } else { echo "No GPS Info"; }

提交回复
热议问题