-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Planetbiru/fearure/2.4
Fearure/2.4
- Loading branch information
Showing
4 changed files
with
508 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace MagicObject\Util\Image; | ||
|
||
class ImageExif | ||
{ | ||
public function getLatLongFromImage($imagePath) { | ||
// Periksa apakah file ada dan dapat dibaca | ||
if (!file_exists($imagePath)) { | ||
return null; | ||
} | ||
|
||
// Ambil data EXIF dari gambar | ||
$exif = exif_read_data($imagePath); | ||
|
||
// Periksa apakah data GPS tersedia | ||
if (isset($exif['GPSLatitude']) && isset($exif['GPSLongitude'])) { | ||
// Ambil nilai latitude dan longitude | ||
$lat = $exif['GPSLatitude']; | ||
$latRef = $exif['GPSLatitudeRef']; | ||
$long = $exif['GPSLongitude']; | ||
$longRef = $exif['GPSLongitudeRef']; | ||
|
||
// Konversi ke format desimal | ||
$latDecimal = $lat[0] + ($lat[1] / 60) + ($lat[2] / 3600); | ||
$longDecimal = $long[0] + ($long[1] / 60) + ($long[2] / 3600); | ||
|
||
// Sesuaikan tanda berdasarkan referensi | ||
if ($latRef === 'S') { | ||
$latDecimal = -$latDecimal; | ||
} | ||
if ($longRef === 'W') { | ||
$longDecimal = -$longDecimal; | ||
} | ||
|
||
return [$latDecimal, $longDecimal]; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.