Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@metadata/exif

1.0.0 • Public • Published

@metadata/exif

npm version

@metadata/exif is fork of JavaScript Library For Reading EXIF Image Metadata. It Reads Files Metadata In The Browser. The package has been optimised with Google Closure Compiler.

The differences to the original package is that at the moment, only the handleBinaryFile method is implemented. There are also some bug-fixes and features, including the options to parse dates into Date object, the coordinates format specification option, and correct parsing of UTF-8 data which was wrong in the origin. The XMP support has been removed for a near future. IPTC tags will have names consistent with exiftool.

yarn add -E @metadata/exif

Table Of Contents

Usage

There are 3 ways to use the package:

  1. As an ES6 module, because the module field of the package.json file is set to src/index.js which exports a ES6 module.
  2. As a CommonJS module, because the main field of the package.json file is set to build/index.js which is the same as the module, but where the import/export statements have been transpiled into module.exports and require.
  3. As a browser bundle, compiled with GCC that sets the window.EXIF object to the package API. To do that, grab the file from the dist folder and add it to the page.

API

During development, the package is available by importing its named functions:

import { handleBinaryData } from '@metadata/exif'

handleBinaryData(
  binFile: ArrayBuffer,
  config?: HandleBinaryFile,
): { data, iptcdata }

Extract metadata from the ArrayBuffer.

Cat

import { inspect } from 'util'
import { readBuffer } from '@wrote/read'
import { handleBinaryFile } from '@metadata/exif'
 
(async () => {
  const { buffer: photo } = (await readBuffer('test/fixture/images/photo.jpg'))
  const res = handleBinaryFile(photo, {
    parseDates: true,
    coordinates: 'dms',
  })
  console.log(inspect(res, null, 100))
})()
{ data: 
   { Make: 'Canon',
     Model: 'Canon EOS 400D DIGITAL',
     Orientation: 1,
     XResolution: { [Number: 72] numerator: 72, denominator: 1 },
     YResolution: { [Number: 72] numerator: 72, denominator: 1 },
     ResolutionUnit: 2,
     DateTime: 2015-06-20T20:10:14.000Z,
     Copyright: '∂éçø',
     ExifIFDPointer: 218,
     GPSInfoIFDPointer: 648,
     ExposureTime: { [Number: 0.04] numerator: 1, denominator: 25 },
     FNumber: { [Number: 1.6] numerator: 8, denominator: 5 },
     ExposureProgram: 'Aperture priority',
     ISOSpeedRatings: 200,
     ExifVersion: '0221',
     DateTimeOriginal: 2015-06-20T20:10:14.000Z,
     DateTimeDigitized: 2015-06-20T20:10:14.000Z,
     ComponentsConfiguration: 'YCbCr',
     ShutterSpeedValue: 4.64385986328125,
     ApertureValue: { [Number: 1.35614013671875] numerator: 22219, denominator: 16384 },
     ExposureBias: 0,
     MaxApertureValue: { [Number: 1.3989796723380756] numerator: 53199, denominator: 38027 },
     MeteringMode: 'Pattern',
     Flash: 'Flash did not fire, compulsory flash mode',
     FocalLength: { [Number: 50] numerator: 50, denominator: 1 },
     FlashpixVersion: '0100',
     ColorSpace: 1,
     PixelXDimension: 250,
     PixelYDimension: 167,
     FocalPlaneXResolution: { [Number: 3210.94640682095] numerator: 2636187, denominator: 821 },
     FocalPlaneYResolution: { [Number: 3230.2405498281787] numerator: 940000, denominator: 291 },
     FocalPlaneResolutionUnit: 2,
     CustomRendered: 'Normal process',
     ExposureMode: 0,
     WhiteBalance: 'Auto white balance',
     SceneCaptureType: 'Standard',
     GPSVersionID: '2.3.0.0',
     GPSLatitudeRef: 'N',
     GPSLatitude: 
      [ { [Number: 40] numerator: 40, denominator: 1 },
        { [Number: 15] numerator: 15, denominator: 1 },
        { [Number: 3.2471999364524584] numerator: 40879, denominator: 12589 } ],
     GPSLongitudeRef: 'W',
     GPSLongitude: 
      [ { [Number: 75] numerator: 75, denominator: 1 },
        { [Number: 7] numerator: 7, denominator: 1 },
        { [Number: 57.5688] numerator: 71961, denominator: 1250 } ],
     thumbnail: {} },
  iptcdata: 
   { Category: 'ANI',
     'Caption-Abstract': 'A black cat looking into the camera.',
     Keywords: [ 'Animal', 'Cat', 'Pet' ],
     Credit: 'Art Deco',
     DateCreated: '20150620',
     'By-lineTitle': [ 'Photographer', 'Owner' ],
     'Writer-Editor': [ 'Art', 'Deco' ],
     Headline: 'Black Cat',
     CopyrightNotice: '© Ã®† ∂éçø 2019, All rights reserved.',
     'By-line': [ 'Anton', 'His Friend' ] } }

_exif.HandleBinaryFile: Options for the handleBinaryFile method.

Name Type Description Default
parseDates boolean Parse EXIF dates into JS dates. false
coordinates string Return coordinates either as DMS (degrees, minutes, seconds) or DD (decimal degrees). Specified as 'dms' or 'dd'. dms

Copyright

(c) Demimonde 2019

Install

npm i @metadata/exif

DownloadsWeekly Downloads

45

Version

1.0.0

License

MIT

Unpacked Size

76.9 kB

Total Files

36

Last publish

Collaborators

  • avatar