Package Exports
- blurhash-map
- blurhash-map/lib/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (blurhash-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
blurhash-map
blurhash-map
Install
npm install blurhash-mapUsage
import { BlurHashMap, BlurHashMapConfig } from 'blurhash-map';
const config: BlurHashMapConfig = {
assetsRoot: 'assets/images/samples',
hashMapJsonPath: 'test/fixtures/lib/hashmap.json',
imageExtensions: 'jpg,png,jpeg',
components: { x: 4, y: 3 },
};
const blurHashMap = new BlurHashMap(config);
blurHashMap.init();
// Now, there should be files created next to images
// with the same name but having `.hash` suffix. You should commit these files
// to avoid re-generate them next time you run `BlurHashMap`.API
BlurHashMap(config)
config
Type: BlurHashMapConfig
assetsRoot: string; // Required. Where to find the images
hashMapJsonPath: string; // Required. Where to save generated JSON
imageExtensions: Array
init()
Initialize BlurHashMap asynchronously. Creates .hash files and generates hash-map.json.
generateOrDelete(imageOrHashFilePath: string, skipIfHasHash = false)
Generates a hash file if image is found. If Image is not found, deletes the .hash file of it.
getShortPath(file: string): string
Returns the relative path of the given file to the assetsRoot
async createJson(): Promise
Creates hash-map.json from the found .hash files