Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
exifreader
Advanced tools
ExifReader is a JavaScript library that parses image files and extracts the metadata. It can be used either in a browser or from Node. Supports JPEG, TIFF, and HEIC files with tags encoded using Exif, IPTC, and XMP (the latter two only for JPEG).
ExifReader supports module formats AMD, CommonJS and globals and can therefore easily be used from Webpack, RequireJS, Browserify, Node etc. Since it is written using ES2015+, you can also import the ES module directly from your own ES2015+ project.
Notes for exif-js users
If you come here from the popular but now dead exif-js package, please let me know if you're missing anything from it and I will try to help you. Some notes:
Easiest is through npm or Bower:
npm install exifreader --save
bower install exifreader --save
If you want to clone the git repository instead:
git clone git@github.com:mattiasw/ExifReader.git
cd ExifReader
npm install
After that, the transpiled, concatenated and minified ES5 file will be in the
dist
folder together with a sourcemap file.
Type definitions for TypeScript are included in the package. If you're missing any definitions for tags or something else, a pull-request would be very much welcome since I'm not using TypeScript myself.
ES modules using a bundler (Webpack, Parcel, etc.):
import ExifReader from 'exifreader';
CommonJS/Node modules:
const ExifReader = require('exifreader');
AMD modules:
requirejs(['/path/to/exif-reader.js'], function (ExifReader) {
...
});
script
tag:
<script src="/path/to/exif-reader.js"></script>
const tags = ExifReader.load(fileBuffer);
const imageDate = tags['DateTimeOriginal'].description;
const unprocessedTagValue = tags['DateTimeOriginal'].value;
By default, Exif, IPTC and XMP tags are grouped together. This means that if
e.g. Orientation
exists in both Exif and XMP, the first value (Exif) will be
overwritten by the second (XMP). If you need to separate between these values,
pass in an options object with the property expanded
set to true
:
const tags = ExifReader.load(fileBuffer, {expanded: true});
fileBuffer
must be an ArrayBuffer
or a SharedArrayBuffer
for
browsers, or a Buffer
for Node. See examples folder for more
directions on how to get the file contents in different environments.
GPSLatitude
, GPSLongitude
) and the
reference value (GPSLatitudeRef
, GPSLongitudeRef
). Use the references to
know whether the coordinate is north/south and east/west. Often you will see
north and east represented as positive values, and south and west
represented as negative values (e.g. in Google Maps). This setup is also
used for the altitude using GPSAltitude
and GPSAltitudeRef
where the
latter specifies if it's above sea level (positive) or below sea level
(negative).Orientation
value of 3
will have Rotate 180
in the description
property. If you would like more XMP tags to have a processed description,
please file an issue or create a pull request.The library makes use of the DataView API which is supported in Chrome 9+, Firefox 15+, Internet Explorer 10+, Edge, Safari 5.1+, Opera 12.1+. If you want to support a browser that doesn't have DataView support, you should probably use a polyfill like jDataView.
Node.js has had support for DataView since version 0.12 but ExifReader will also try to polyfill it for versions before that (this is not well tested though).
Full HTML example pages and a Node.js example are located in the examples/ directory.
Testing is done with Mocha and Chai. Run with:
npm test
Test coverage can be generated like this:
npm run coverage
See CONTRIBUTING.md.
This project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
ExifReader uses the Mozilla Public License 2.0 (MPL-2.0). In short that means you can use this library in your project (open- or closed-source) as long as you mention the use of ExifReader and make any changes to ExifReader code available if you would to distribute your project. But please read the full license text to make sure your specific case is covered.
FAQs
Library that parses Exif metadata in images.
The npm package exifreader receives a total of 25,037 weekly downloads. As such, exifreader popularity was classified as popular.
We found that exifreader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.