Fast EXIF extraction without reading whole file into memory.
npm install fast-exif
Because you do not need to read megabytes of JPEG to obtain EXIF. 512 bytes should be enough.
``bash`
npm i fast-exif --save
`js`
const exif = require("fast-exif");
exif.read("my.jpg").then(console.log).catch(console.error);
``
{ image:
{ Make: 'Canon',
Model: 'Canon EOS 30D',
Orientation: 1,
XResolution: 72,
YResolution: 72,
ResolutionUnit: 2,
Software: 'Aperture 3.4.3',
ModifyDate: Tue Dec 25 2012 04:25:39 GMT+0200 (EET),
ExifOffset: 194 },
exif:
{ ExposureTime: 0.0015625,
FNumber: 10,
ExposureProgram: 3,
ISO: 1250,
ExifVersion:
DateTimeOriginal: Tue Dec 25 2012 04:25:39 GMT+0200 (EET),
DateTimeDigitized: Tue Dec 25 2012 04:25:39 GMT+0200 (EET),
ComponentsConfiguration:
ShutterSpeedValue: 9.321929824561403,
ApertureValue: 6.643859649122807,
ExposureBiasValue: -0.3333333333333333,
MaxApertureValue: 5.595918367346939,
MeteringMode: 5,
Flash: 16,
FocalLength: 18,
FlashpixVersion:
ColorSpace: 1,
PixelXDimension: 1613,
PixelYDimension: 1075,
FocalPlaneXResolution: 3959.322033898305,
FocalPlaneYResolution: 3959.322033898305,
FocalPlaneResolutionUnit: 2,
CustomRendered: 0,
ExposureMode: 0,
WhiteBalance: 0,
SceneCaptureType: 0 } }
Because most popular npm module for exif reads complete file into memory causing OOM kill.
If fast-exif returned null instead of object with EXIF info, then
- either file does not have any EXIF info
- or EXIF marker is located outside of first 512 bytes
In such case
- specify number of 512-byte blocks to examine while searching for EXIF (exif.read('my.jpeg', 20))true
- or specify for unlimited (to the end of file) search (exif.read('my.jpeg', true)`)
MIT