Is it possible and how to add some data in XMP Metadata? For example I want to save this two values (employee name and version) to XMP. I try something with AI but not successfully This is draft of my react component . Thanks in advance
import React, { useState } from 'react';
const { core } = require('photoshop');
const uxp = require('uxp');
const Info = () => {
const [retoucher, setRetoucher] = useState('');
const [version, setVersion] = useState('');
const handleSave = async () => {
const XMP = uxp.storage.XMP;
try {
const app = require('photoshop').app;
const activeDocument = app.activeDocument;
const xmp = await XMP.fromDocument(activeDocument);
const namespace = "http://testPlugin.com/ns/";
xmp.setProperty(namespace, "retoucher", retoucher);
xmp.setProperty(namespace, "version", version);
await xmp.applyToDocument(activeDocument);
console.log('XMP metadata successfully saved.');
alert('XMP metadata successfully updated!');
} catch (error) {
console.error('Error saving XMP metadata:', error);
alert('An error occurred while saving XMP metadata: ' + error.message);
}
};
return (
<>
<sp-heading>INFO</sp-heading>
<div>
<label>Retoucher: </label>
<input
type="text"
value={retoucher}
onChange={(e) => setRetoucher(e.target.value)}
/>
</div>
<div>
<label>Version: </label>
<input
type="text"
value={version}
onChange={(e) => setVersion(e.target.value)}
/>
</div>
<div className="confirmBtns">
<sp-button onClick={handleSave} size="m" quiet variant="accent">Run</sp-button>
</div>
</>
);
};
export default Info;