@danielbiegler/vendure-plugin-blurry-image-lazy-loading
Version:
Generates image hashes for displaying blurry previews when loading images on the frontend.
48 lines (47 loc) • 1.24 kB
TypeScript
/// <reference types="node" />
import sharp from "sharp";
import { PluginPreviewImageHashCreateInput } from "../generated-admin-types";
/**
* @category Strategy
*/
export interface PreviewImageHashStrategy {
/**
* Generates the image hash
*
* WARNING: This function mutates the sharp object!
*
* @returns Preview Hash
*/
encode(buffer: sharp.Sharp, input: PluginPreviewImageHashCreateInput): Promise<string>;
}
/**
* @category Strategy
*/
export type PreviewImageHashBaseArgs = {
resizeOptions?: sharp.ResizeOptions;
encoding?: BufferEncoding;
};
/**
* Shared logic and values to reduce the boilerplate inside strategies
*
* @category Strategy
*/
export declare abstract class PreviewImageHashBase {
default: {
readonly width: 64;
readonly background: {
readonly r: 255;
readonly g: 255;
readonly b: 255;
readonly alpha: 1;
};
readonly encoding: "base64";
};
resizeOptions: sharp.ResizeOptions;
encoding: BufferEncoding;
/**
* Clones the resize options so as to not mutate the passed in object.
* @see args.resizeOptions
*/
constructor(args: PreviewImageHashBaseArgs);
}