broccoli-image-meta

2.0.3 • Public • Published

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

Option Type Defaults Description
outputFile String meta.json Output file name
extensions Array ['jpg', 'jpeg', 'gif', 'png'] Files to be processed
filters Array [] Image preprocessors
persist Boolean true Use disk cache
formatOutput Function (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

Package Sidebar

Install

npm i broccoli-image-meta

Weekly Downloads

2

Version

2.0.3

License

MIT

Unpacked Size

52.4 kB

Total Files

19

Last publish

Collaborators

  • bbvaengineer