JSPM

blurhash-map

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q31131F
  • License MIT

A template for creating npm packages using TypeScript and VSCode

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

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

blurhash-map

Install

npm install blurhash-map

Usage

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; // Optional. Define which image files. Default : 'jpg' | 'jpeg' | 'png' | 'bmp' | 'webp' components?: { x: number; y: number }; // Optional between 1-9. Default {x:4,y:3}. Higher is more detailed blur but longer string

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