import sharp from 'sharp' ; import { ImageConfig } from './types' ; import { createHash } from 'crypto' ; export function loadImage ( path ) { return sharp ( path ) ; } export function generateImageID ( url , config ) { const baseURL = url . host ? new URL ( url . origin + url . pathname ) : new URL ( url . protocol + url . pathname ) ; return createHash ( 'sha1' ) . update ( baseURL . href ) . update ( JSON . stringify ( config ) ) . digest ( 'hex' ) ; }