Open klaussa opened 7 years ago
Which value do you want to add? Example:
var s = "foo";
var bytes = [];
for (var i=0; i<s.length; i++) {
bytes.push(s.charCodeAt(i));
}
bytes -> [102, 111, 111]
@hMatoba
I want to add a piece of text to those fields.
// XPTitle: // XPComment: // XPAuthor: // XPKeywords: // XPSubject
The example you provided doesn't output foo but outputs a chinese character :(
I use this to check: http://metapicz.com/#landing ( + also I do windows -> properties -> details tab to check ).
Any advice ?
The Code looks like:
It need to encode and decode as UCS2. Read the specification. http://www.exiv2.org/tags.html
@klaussa finding the answer not straightforward, but this was my solution (using Node.js v12 and the new spread syntax):
exif[piexifjs.ImageIFD.XPTitle]: [...Buffer.from('Your XPTitle', 'ucs2')]
For more information, see: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings https://nodejs.org/api/buffer.html#buffer_buffers_and_typedarrays Other background info: https://www.npmjs.com/package/punycode https://mathiasbynens.be/notes/javascript-encoding
its saying uncaught pack error, when i used [...Buffer.from('Your XPTitle', 'ucs2')] using vue 3 js
In my case this issue happened due to big number in exifObj['GPS'][piexif.GPSIFD.GPSTimeStamp]
.
But it definitely depends. It can be related to any EXIF field. Not only GPS related.
Hi,
I have been trying to figure out the way to convert a string for XPSubject into the required format. Can anyone please provide more guidance / examples on how the conversion between BYTE to javascrpt Int works ? ( i am considering to put text into subject )
thank you