GithubHelp home page GithubHelp logo

superdesk / exif Goto Github PK

View Code? Open in Web Editor NEW

This project forked from demimonde/exif

0.0 2.0 0.0 200 KB

Reads Files Metadata In The Browser.

Home Page: https://demimonde.cc

License: Other

JavaScript 100.00%

exif's Introduction

@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-20T21: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-20T21:10:14.000Z,
     DateTimeDigitized: 2015-06-20T21: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: 
   { ObjectName: 'cat',
     EditStatus: 'resized',
     Category: 'ANI',
     Urgency: '5',
     '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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.