ApeironTsuka / node-webpmux

A mostly 1:1 re-implementation of webpmux as a Node module in pure Javascript. Only thing currently missing is a command-line version.
GNU Lesser General Public License v3.0
26 stars 8 forks source link

How to write an EXIF file in a webp #9

Closed GladistonXD closed 3 years ago

GladistonXD commented 3 years ago

webpmux -set exif image_metadata.exif in.webp -o exif_container.webp

I would like to use exactly this command only for node

I tried something like:

let img = new WebP.Image()

await img.load('in.webp')

img.exif = 'mage_metadata.exif'

await img.save('exif_container.webp')

I did not succeed

ApeironTsuka commented 3 years ago

The .exif property, along with the other metadata properties (.xmp and .iccp) are the raw data. You would instead do something like

const WebP = require('node-webpmux'), fs = require('fs/promises')
let img = new WebP.Image();
await img.load('in.webp');
img.exif = await fs.readFile('image_metadata.exif');
await img.save('exif_container.webp');

assigning the contents of the image_metadata.exif file directly rather than the filename. I'll update the README to clarify this after I think of a good way to word it.

GladistonXD commented 3 years ago

Now it worked perfectly, thank you very much :)