- ลองเอาภาพธรรมดามาใส่ GPS ใน Ligthroom เเต่ก็ยังไม่สามารถถอดได้ (ไม่เเน่ใจทำอะไรผิด)
- ถ้าใครต้องการ GPX File สามารถ Export จาก Ligthroom ได้
โค้ด: เลือกทั้งหมด
test_photo.jpg:
Image contains headers
test_photo.jpg:
Array ( [FILE] => Array ( [FileName] => test_photo.jpg [FileDateTime] => 1454262383 [FileSize] => 535942 [FileType] => 2 [MimeType] => image/jpeg [SectionsFound] => ANY_TAG, IFD0, EXIF, GPS ) [COMPUTED] => Array ( [html] => width="1024" height="683" [Height] => 683 [Width] => 1024 [IsColor] => 1 [ByteOrderMotorola] => 0 [ApertureFNumber] => f/11.0 [Copyright] => ยฉ 2012 - Bhachara Chayraksa ) [IFD0] => Array ( [Make] => NIKON CORPORATION [Model] => NIKON D3100 [XResolution] => 350/1 [YResolution] => 350/1 [ResolutionUnit] => 2 [Software] => Adobe Photoshop Lightroom 4.0 (Windows) [DateTime] => 2013:01:12 23:50:05 [Artist] => Bhachara Chayraksa [Copyright] => ยฉ 2012 - Bhachara Chayraksa [Exif_IFD_Pointer] => 302 [GPS_IFD_Pointer] => 904 ) [EXIF] => Array ( [ExposureTime] => 1/500 [FNumber] => 11/1 [ExposureProgram] => 2 [ISOSpeedRatings] => 400 [ExifVersion] => 0230 [DateTimeOriginal] => 2013:01:12 11:02:54 [DateTimeDigitized] => 2013:01:12 11:02:54 [ShutterSpeedValue] => 8965784/1000000 [ApertureValue] => 6918863/1000000 [ExposureBiasValue] => 0/6 [MaxApertureValue] => 43/10 [MeteringMode] => 5 [LightSource] => 0 [Flash] => 0 [FocalLength] => 350/10 [SubSecTimeOriginal] => 80 [SubSecTimeDigitized] => 80 [SensingMethod] => 2 [FileSource] => [SceneType] => [CFAPattern] => [CustomRendered] => 0 [ExposureMode] => 0 [WhiteBalance] => 0 [DigitalZoomRatio] => 1/1 [FocalLengthIn35mmFilm] => 52 [SceneCaptureType] => 1 [GainControl] => 1 [Contrast] => 0 [Saturation] => 0 [Sharpness] => 0 [SubjectDistanceRange] => 0 [UndefinedTag:0xA431] => 2034564 [UndefinedTag:0xA432] => Array ( [0] => 180/10 [1] => 1050/10 [2] => 35/10 [3] => 56/10 ) [UndefinedTag:0xA434] => 18.0-105.0 mm f/3.5-5.6 ) [GPS] => Array ( [GPSLatitudeRef] => N [GPSLatitude] => Array ( [0] => 13/1 [1] => 426639/10000 [2] => 0/0 ) [GPSLongitudeRef] => E [GPSLongitude] => Array ( [0] => 100/1 [1] => 306408/10000 [2] => 0/0 ) ) )
โค้ด: เลือกทั้งหมด
[GPS] => Array
(
[GPSLatitudeRef] => N
[GPSLatitude] => Array
(
[0] => 13/1
[1] => 426639/10000
[2] => 0/0
)
[GPSLongitudeRef] => E
[GPSLongitude] => Array
(
[0] => 100/1
[1] => 306408/10000
[2] => 0/0
)
)
โค้ด: เลือกทั้งหมด
<?php
echo "test_photo.jpg:<br />\n";
$exif = exif_read_data('test/test_photo.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";
$exif = exif_read_data('test/test_photo.jpg', 0, true);
echo "test_photo.jpg:<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
echo '<hr>';
โค้ด: เลือกทั้งหมด
$image_file = 'test/test_photo.jpg';
if(file_exists($image_file)){
$details = exif_read_data($image_file);
//print_r($details);
$sections = explode(',',$details['SectionsFound']);
if(in_array('GPS',array_flip($sections))){
echo format_gps_data($details['GPSLatitude'],$details['GPSLatitudeRef']);
echo '<br/>';
echo format_gps_data($details['GPSLongitude'],$details['GPSLongitudeRef']);
}else{
die('GPS data not found');
}
}else{
die('File does not exists');
}
function format_gps_data($gpsdata,$lat_lon_ref){
$gps_info = array();
foreach($gpsdata as $gps){
list($j , $k) = explode('/', $gps);
@array_push($gps_info,$j/$k);
}
$coordination = $gps_info[0] + ($gps_info[1]/60.00) + ($gps_info[2]/3600.00);
return (($lat_lon_ref == "S" || $lat_lon_ref == "W" ) ? '-'.$coordination : $coordination).' '.$lat_lon_ref;
}
โค้ด: เลือกทั้งหมด
13.711065 N
100.51068 E
โค้ด: เลือกทั้งหมด
extension=php_exif.dll
extension=php_mbstring.dll
http://pantip.com/topic/30041407