I want to get exif data from uploaded picture such as lat, long of taken picture
I try to use PIL Image to extract after uploaded but it has error occurred then I download the file and found that the exif data has been removed from the file.
PS: I also remove optimize option during upload picture
thanks.
Maybe add an upload button with a custom upload function, that besides uploading the file as-is, it also uses PIL to get whatever exif data you need…
you means, do not use the standard function or hooks the standard function. please give me the idea
Let’s start by selecting a standard folder in which you place your pictures (e.g. a network location, or a local folder):
//smb-server/public/pictures
Keep this folder mounted on your frappe server (e.g.: at /path/to/server/folder
)
Now, in your doctype you can place a button for selecting the picture.
Something like:
frappe.ui.form.on('Your DocType', {
img_select(frm) { //a button
var input = document.createElement('input');
input.type = 'file';
input.onchange = e => {
var file = e.target.files[0].name;
var folder = `/home/frappe/frappe/bench/sites/${window.location.origin.split('/')[-1]}/files/${file}`
frappe.call({method:'whitelisted_server_side_function', //this function does what it wants, and copies the file from '/path/to/server/folder' to {$folder}
args: {
'filename': file,
'folder': folder //you can have this hardcoded if you wish
}
}).then(r => {
var data = r.message.exif_data;
//do whatever with exif data
frm.set_value('img_file',`${window.location.origin}/files/${file}`); //a data feild with URL option should work
frm.refresh('img_file');
});
};
input.click();
}
});