-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Take this code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Exiftool Web</title>
<!-- https://github.com/eligrey/FileSaver.js/ -->
<script defer src="https://cdn.jsdelivr.net/npm/file-saver@2/dist/FileSaver.min.js"></script>
</head>
<body style="padding:1rem">
<h3>Exiftool Web</h3>
<input id="files" type="file" />
<script type="module">
// https://github.com/6over3/exiftool
import * as exiftool from 'https://cdn.jsdelivr.net/npm/@uswriting/exiftool@1/+esm'
document.getElementById('files').addEventListener('change', async (event) => {
// https://exiftool.org/exiftool_pod.html#Option-Overview
const file = event.target.files[0];
console.log('Filename=' + file.name);
const tags = {
"IPTC:Credit": "XXXXXX",
"IPTC:Headline": "XXXXXX",
"IPTC:Keywords": "XXXXXX",
"IPTC:ReleaseDate": '',
"IPTC:ReleaseTime": '',
"IPTC:Caption-Abstract": "XXXXXX",
"XMP-photoshop:Credit": "XXXXXX",
"XMP-photoshop:Headline": "XXXXXX",
"XMP-dc:Subject": ["XXXXXX", "XXXXXX", "XXXXXX"],
"XMP-dc:Description": "XXXXXX"
};
const result = await exiftool.writeMetadata(file, tags);
if (result.success) {
const blob = new Blob([result.data], { type: 'image/jpeg' });
saveAs(blob, "EDITED " + file.name);
} else {
console.error("Error:", result.error);
alert(result.error);
}
});
</script>
</body>
</html>
Try loading this foto:
You will notice that the XMP tags were not written to the file:
"XMP-photoshop:Credit": "XXXXXX",
"XMP-photoshop:Headline": "XXXXXX",
"XMP-dc:Subject": ["XXXXXX", "XXXXXX", "XXXXXX"],
"XMP-dc:Description": "XXXXXX"
And there are no error messages on the console.
And in some other cases, no tags are written, and the file is returned as is with no changes and also no error messages..
Metadata
Metadata
Assignees
Labels
No labels