2.0.3 • Published 5 years ago

broccoli-image-meta v2.0.3

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

broccoli-image-meta

Build Status GitHub version NPM version Dependency Status codecov Greenkeeper badge

Information

NPM

Process a source of images and generate a JSON with image metadata.

Why? For example, to create a component able to load a thumbnail or a colored box while the real image still loading.

Installation & usage

npm install --save broccoli-image-meta

// Raw
const ImageMeta = require('broccoli-image-meta');
const { color, dimensions } = ImageMeta;

const myTree = new Funnel('assets/images');
const thumbnailTree = new ImageMeta(myTree, {
  outputFile: 'meta.json',
  globs: [
    '**/*.{jpg,jpeg,gif,png}'
  ],
  filters: [color, dimensions]
});
// Ember addon style
const BroccoliImageMeta = require('broccoli-image-meta');

module.exports = {
  // ...

  treeForPublic() {
    return new BroccoliImageMeta('assets/images', { /* options */ });
  }
};

Options

OptionTypeDefaultsDescription
outputFileStringmeta.jsonOutput file name
extensionsArray['jpg', 'jpeg', 'gif', 'png']Files to be processed
filtersArray[]Image preprocessors
persistBooleantrueUse disk cache
formatOutputFunction(meta) => JSON.stringify(meta)Content to write inside the output file

Filters

The filter is just a Function that must return an Object (promise compatible) and receiver an Entry (an object with basePath and relativePath). The object will be merged with the rest of the data created by other filters.

Examples in lib/filters/.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details