Merge pull request #7 from j-calvert/exif-parse
Seems to be working to parse GPS out of EXIF data within image.
This commit is contained in:
commit
3b1e0e0c35
|
@ -1,6 +1,13 @@
|
|||
function convertDMSToDD([degrees, minutes, seconds], ref) {
|
||||
decimal_degrees = degrees + minutes / 60 + seconds / 3600;
|
||||
if (ref == 'S' || ref == 'W') {
|
||||
decimal_degrees = -decimal_degrees;
|
||||
}
|
||||
return decimal_degrees;
|
||||
}
|
||||
|
||||
function readURL(input) {
|
||||
if (input.files && input.files[0]) {
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
|
@ -10,10 +17,32 @@ function readURL(input) {
|
|||
$('.file-upload-content').show();
|
||||
|
||||
$('.image-title').html(input.files[0].name);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.src = e.target.result;
|
||||
|
||||
// Render thumbnail.
|
||||
img.onload = function () {
|
||||
EXIF.getData(img, function () {
|
||||
var allMetaData = EXIF.getAllTags(this);
|
||||
var allMetaDataSpan = document.getElementById('allMetaDataSpan');
|
||||
// allMetaDataSpan.innerHTML = JSON.stringify(allMetaData, null, '\t');
|
||||
var lat = convertDMSToDD(
|
||||
EXIF.getTag(this, 'GPSLatitude'),
|
||||
EXIF.getTag(this, 'GPSLatitudeRef')
|
||||
);
|
||||
var long = convertDMSToDD(
|
||||
EXIF.getTag(this, 'GPSLongitude'),
|
||||
EXIF.getTag(this, 'GPSLongitudeRef')
|
||||
);
|
||||
$('#lat').val(lat);
|
||||
$('#long').val(long);
|
||||
console.log(`lat: ${lat}, long: ${long}`);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
|
||||
} else {
|
||||
removeUpload();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- EXIF JS -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/exif-js/2.3.0/exif.js" integrity="sha512-bE9sOOprru4D2nRKDQSNvhdxw47Jd0r2s7QThKB/KkU5HEPuxsk9DbK+fYIMCYlCsXkwp6M87vj84sAtYWqxvw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<!-- Then Material JavaScript on top of Bootstrap JavaScript -->
|
||||
<script src="/assets/material/material.min.js"></script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue