Skip to content

Commit

Permalink
feat(imagetools-core): Add image id generation utility
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg committed Mar 19, 2021
1 parent 86c1a3a commit 9e0673d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import sharp, { Sharp } from "sharp";
import sharp from "sharp";
import { ImageConfig } from "./types";
import { createHash } from 'crypto'

export function loadImageFromDisk(path: string) {
return sharp(path)
}

export function loadImageFromBuffer(buf: Buffer) {
return sharp(buf)
}

export function generateImageID(config:ImageConfig) {
return createHash('sha1').update(JSON.stringify(config)).digest('hex')
}

0 comments on commit 9e0673d

Please sign in to comment.