Skip to content

Commit

Permalink
c2pa data from image urls functional
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrks committed Aug 8, 2024
1 parent 56a7a51 commit 7647ddd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/components/NavItems/tools/C2pa/C2pa.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ const C2paData = () => {
const keyword = i18nLoadNamespace("components/NavItems/tools/C2pa");

const handleSubmit = () => {
dispatch(c2paStateCleaned());

if (imageFile) {
dispatch(c2paStateCleaned());
getC2paData(imageFile, dispatch);
const url = URL.createObjectURL(imageFile);
getC2paData(url, dispatch);
} else if (input) {
getC2paData(input, dispatch);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/NavItems/tools/C2pa/Hooks/useGetC2paData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ async function getToolkitSettings() {

/**
*
* @param {Object} image the image containing c2pa data
* @param {Object} url the url of the image containing c2pa data
* @param {function} dispatch
*/

async function getC2paData(image, dispatch) {
async function getC2paData(url, dispatch) {
const settings = await getToolkitSettings();

const c2pa = await createC2pa({
Expand All @@ -226,10 +226,10 @@ async function getC2paData(image, dispatch) {
});

dispatch(c2paLoadingSet(true));
const url = URL.createObjectURL(image);
// const url = URL.createObjectURL(image);

try {
const { manifestStore } = await c2pa.read(image, {
const { manifestStore } = await c2pa.read(url, {
settings: settings,
});

Expand Down

0 comments on commit 7647ddd

Please sign in to comment.