broccoli-image-meta
v2.0.3
Published
Get meta data from a given image tree
Downloads
9
Maintainers
Readme
broccoli-image-meta
Information
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.
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