next-blurhash-previews 0.0.3-beta27 → 0.0.3-beta28
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/generateBlurhash.js +8 -2
- package/package.json +1 -1
package/bin/generateBlurhash.js
CHANGED
@@ -21,11 +21,17 @@ export async function getBlurhash(path) {
|
|
21
21
|
const blurhashImage = await getSharpImage(path);
|
22
22
|
const dimensions = await blurhashImage.metadata();
|
23
23
|
|
24
|
-
|
24
|
+
let { width, height } = dimensions;
|
25
|
+
|
26
|
+
if (width > 200) {
|
27
|
+
let newMetadata = await blurhashImage.resize(200).metadata();
|
28
|
+
width = newMetadata.width;
|
29
|
+
height = newMetadata.height;
|
30
|
+
}
|
25
31
|
|
26
32
|
return new Promise((res, rej) => {
|
27
33
|
blurhashImage
|
28
|
-
.resize(Math.min(width
|
34
|
+
.resize(Math.min(width))
|
29
35
|
.raw()
|
30
36
|
.ensureAlpha()
|
31
37
|
.toBuffer((err, buffer) => {
|