@travetto/image 5.0.15 → 5.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -3
- package/src/util.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/image",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.17",
|
|
4
4
|
"description": "Image support, resizing, and optimization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"images",
|
|
@@ -23,11 +23,16 @@
|
|
|
23
23
|
"directory": "module/image"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/runtime": "^5.0.
|
|
26
|
+
"@travetto/runtime": "^5.0.13",
|
|
27
27
|
"sharp": "^0.33.5"
|
|
28
28
|
},
|
|
29
29
|
"travetto": {
|
|
30
|
-
"displayName": "Image"
|
|
30
|
+
"displayName": "Image",
|
|
31
|
+
"build": {
|
|
32
|
+
"binaryDependencies": [
|
|
33
|
+
"sharp"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
31
36
|
},
|
|
32
37
|
"publishConfig": {
|
|
33
38
|
"access": "public"
|
package/src/util.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { createReadStream } from 'node:fs';
|
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
import { ReadableStream } from 'node:stream/web';
|
|
4
4
|
import { pipeline } from 'node:stream/promises';
|
|
5
|
-
import { Metadata } from 'sharp';
|
|
5
|
+
import type { Metadata } from 'sharp';
|
|
6
6
|
|
|
7
7
|
import { castTo } from '@travetto/runtime';
|
|
8
8
|
|
|
9
|
-
type ImageFormat = 'jpeg' | 'png' | 'avif' | 'webp';
|
|
9
|
+
type ImageFormat = 'jpeg' | 'png' | 'avif' | 'webp' | 'gif' | 'jxl';
|
|
10
10
|
type Input = Buffer | string | ReadableStream | Readable;
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -57,7 +57,9 @@ export class ImageUtil {
|
|
|
57
57
|
.avif({ force: format === 'avif', ...optimize ? { quality: 70 } : {} })
|
|
58
58
|
.webp({ force: format === 'webp', ...optimize ? { quality: 80 } : {} })
|
|
59
59
|
.png({ force: format === 'png', ...optimize ? { compressionLevel: 9, quality: 80, adaptiveFiltering: true } : {} })
|
|
60
|
-
.jpeg({ force: format === 'jpeg', ...optimize ? { quality: 80, progressive: true } : {} })
|
|
60
|
+
.jpeg({ force: format === 'jpeg', ...optimize ? { quality: 80, progressive: true } : {} })
|
|
61
|
+
.jxl({ force: format === 'jxl', ...optimize ? { lossless: false, quality: 80 } : {} })
|
|
62
|
+
.gif({ force: format === 'gif', ...optimize ? { effort: 10 } : {} });
|
|
61
63
|
|
|
62
64
|
const stream = Buffer.isBuffer(image) ?
|
|
63
65
|
Readable.from(image) :
|