Seems to be working to parse GPS out of EXIF data within image.
This commit is contained in:
parent
2673bbe617
commit
79486d9734
|
@ -1,34 +1,53 @@
|
|||
function convertDMSToDD([degrees, minutes, seconds]) {
|
||||
return degrees + minutes / 60 + seconds / 3600;
|
||||
}
|
||||
|
||||
function readURL(input) {
|
||||
if (input.files && input.files[0]) {
|
||||
if (input.files && input.files[0]) {
|
||||
var reader = new FileReader();
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
$('.image-upload-wrap').hide();
|
||||
|
||||
reader.onload = function(e) {
|
||||
$('.image-upload-wrap').hide();
|
||||
$('.file-upload-image').attr('src', e.target.result);
|
||||
$('.file-upload-content').show();
|
||||
|
||||
$('.file-upload-image').attr('src', e.target.result);
|
||||
$('.file-upload-content').show();
|
||||
$('.image-title').html(input.files[0].name);
|
||||
|
||||
$('.image-title').html(input.files[0].name);
|
||||
};
|
||||
var img = document.createElement('img');
|
||||
img.src = e.target.result;
|
||||
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
// 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'));
|
||||
var long = convertDMSToDD(EXIF.getTag(this, 'GPSLongitude'));
|
||||
$('#lat').val(lat);
|
||||
$('#long').val(long);
|
||||
console.log(`lat: ${lat}, long: ${long}`);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
removeUpload();
|
||||
}
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
} else {
|
||||
removeUpload();
|
||||
}
|
||||
}
|
||||
|
||||
function removeUpload() {
|
||||
$('.file-upload-input').replaceWith($('.file-upload-input').clone());
|
||||
$('.file-upload-content').hide();
|
||||
$('.image-upload-wrap').show();
|
||||
$('.file-upload-input').replaceWith($('.file-upload-input').clone());
|
||||
$('.file-upload-content').hide();
|
||||
$('.image-upload-wrap').show();
|
||||
}
|
||||
|
||||
$('.image-upload-wrap').bind('dragover', function() {
|
||||
$('.image-upload-wrap').addClass('image-dropping');
|
||||
$('.image-upload-wrap').bind('dragover', function () {
|
||||
$('.image-upload-wrap').addClass('image-dropping');
|
||||
});
|
||||
|
||||
$('.image-upload-wrap').bind('dragleave', function() {
|
||||
$('.image-upload-wrap').removeClass('image-dropping');
|
||||
$('.image-upload-wrap').bind('dragleave', function () {
|
||||
$('.image-upload-wrap').removeClass('image-dropping');
|
||||
});
|
|
@ -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