Package Exports
- modify-exif
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (modify-exif) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
modify-exif
Modify Exif data of a JPEG and create a new Buffer
const {readFile} = require('fs').promises;
const getExif = require('get-exif');
const modifyExif = require('modify-exif');
(async () => {
// The original photo is taken at 2017:11:19 08:47:19
const originalFile = await readFile('example.jpg');
getExif(originalFile).Exif; //=> '2017:11:19 08:47:19'
const newFile = modifyExif(await readFile('example.jpg'), data => {
// 36867: tag ID of `DateTimeOriginal` tag
data.Exif['36867'] = '2018:06:15 12:00:00'
});
getExif(newFile).Exif; //=> '2018:06:15 12:00:00'
})();
Installation
npm install modify-exif
API
const modifyExif = require('modify-exif');
modifyExif(buffer, modifierFn [, option])
buffer: Buffer
(data of a JPEG file)
modifierFn: Function
(a function to transform a passed Object
inside it)
option: Object
Return: Object
It reads Exif data from a Buffer
using Piexifjs, pass it to the modifier function and return a new Buffer
of the image with updated Exif data.
Note that the original Buffer
is not modified.
const newBuffer = modifyExif(imageBuffer, data => {
data; /*=> {
'0th': { ... },
'1st': { ... },
Exif: { ... },
GPS: { ... }
Interop: { ... },
thumbnail: ' ... '
} */
// 305: tag ID of `Software` tag
data['0th'][305] = 'My Camera'
});
option.keepDateTime
Type: boolean
Default: false
By default DataTime
tag (file change date and time) of the 0th IFD is updated to the current date and time.
true
disables this behavior.
License
ISC License © 2018 Shinnosuke Watanabe