0.1.0 • Published 7 years ago

metalsmith-media-metadata v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

metalsmith-media-metadata

build status codecov Greenkeeper badge

Adds metadata to image and video metalsmith file objects. Only really useful when used in conjunction with other plugins.

Example

The output of exiftool is added as metadata into the metalsmith file object for any media file:

{
  'dog.jpg': {
    // Existing file data untouched
    exif: {
      Sharpness: 'Normal',
      SubjectDistanceRange: 'Unknown',
      GPSLatitudeRef: 'North',
      GPSLongitudeRef: 'East',
      GPSAltitudeRef: 'Above Sea Level',
      GPSTimeStamp: '14:27:07.24',
      GPSSatellites: '06',
      GPSImgDirectionRef: 'Unknown ()',
      GPSMapDatum: 'WGS-84   ',
      GPSDateStamp: '2008:10:23',
      Compression: 'JPEG (old-style)',
      ThumbnailOffset: 4560,
      ThumbnailLength: 6702,
      ImageWidth: 640,
      ImageHeight: 480,
      EncodingProcess: 'Baseline DCT, Huffman coding',
      BitsPerSample: 8,
      ColorComponents: 3,
      // Many, many fields...
    }
  }
}

Usage

const mediaMetadata = require('metalsmith-media-metadata');

metalsmith.use(mediaMetadata({
  // Only process jpegs
  path: '**/*.+(jpg|jpeg)'
}));

There are two configuration options:

  • cache: Save exif data alongside images (default: false)
  • path: minimatch case-insensitive glob that determines which files get processed (default: **/*.+(gif|jpg|mp4|png))

Requirements

Changelog

  • 0.1.0: Add cache option
  • 0.0.4: Update default search path to match subdirectories
  • 0.0.3: Fix bug where paths were not relative to metalsmith.source()
  • 0.0.2: Package metadata update, no changes
  • 0.0.1: Initial release

Related plugins

  • metalsmith-image-dimensions: Adds width and height to img tags.

Miscellaneous

Sample images used in tests taken from ianare/exif-samples

Sample video from the Internet Archive