-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Thanks to "copilot" I got it running with these steps:
a) create and change into a new directory in your Ubuntu (or other linux-like Distro):
mkdir exiftool-example
cd exiftool-example
b) create a new npm project:
npm init -y
c) install vite and @uswriting/exiftool:
npm install vite @uswriting/exiftool
d) create an index.html file with this content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ExifTool Example</title>
</head>
<body>
<input type="file" />
<script type="module" src="/main.js"></script>
</body>
</html>
e) create a main.js file with this content:
import { parseMetadata } from '@uswriting/exiftool';
document.querySelector('input[type="file"]').addEventListener('change', async (event) => {
const file = event.target.files[0];
const result = await parseMetadata(file);
if (result.success) {
console.log(result.data);
} else {
console.error('Error:', result.error);
}
});
f) create a vite.config.js file with this content:
export default {
root: '.',
}
g) start the vite development server with:
npx vite
(If you want to expose it to your network, use
npx vite --host
h) click with the pressed CTRL key on the link presented in the terminal window, something like
http://localhost:5173/
or (i fnpx vite started with --host)
http://10.255.255.254:5173/
i) Now you can choose a file in the opened standard browser.
The extracted information from exiftool can be found if you open the Inspect part of your browser (F12) and have a look at the console output.
Hope this helps other N00bs like me .-)
If anyone knows an easier way for beginners, please let me know.