@travetto/image 2.0.2 → 2.1.1
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 +2 -2
- package/src/util.ts +5 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/image",
|
|
3
3
|
"displayName": "Image",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"description": "Image support, resizing, and optimization",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"images",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"directory": "module/image"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/command": "^2.
|
|
27
|
+
"@travetto/command": "^2.1.1"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
2
|
|
|
3
3
|
import { CommandService } from '@travetto/command';
|
|
4
4
|
import { ExecUtil, StreamUtil, AppCache, FsUtil } from '@travetto/boot';
|
|
@@ -33,8 +33,8 @@ export class ImageUtil {
|
|
|
33
33
|
* Resize/conversion util
|
|
34
34
|
*/
|
|
35
35
|
static CONVERTER = new CommandService({
|
|
36
|
-
containerImage: '
|
|
37
|
-
localCheck: ['
|
|
36
|
+
containerImage: ' jameskyburz/graphicsmagick-alpine:v1.0.0',
|
|
37
|
+
localCheck: ['gm', ['-version']]
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -60,7 +60,7 @@ export class ImageUtil {
|
|
|
60
60
|
static resize(image: Buffer, options: ImageOptions): Promise<Buffer>;
|
|
61
61
|
static async resize(image: ImageType, options: ImageOptions): Promise<NodeJS.ReadableStream | Buffer> {
|
|
62
62
|
const state = await this.CONVERTER.exec(
|
|
63
|
-
'convert', '-resize', `${options.w ?? ''}x${options.h ?? ''}`,
|
|
63
|
+
'gm', 'convert', '-resize', `${options.w ?? ''}x${options.h ?? ''}`,
|
|
64
64
|
'-auto-orient',
|
|
65
65
|
...(options.optimize ? ['-strip', '-quality', '86'] : []),
|
|
66
66
|
'-', '-');
|
|
@@ -108,6 +108,6 @@ export class ImageUtil {
|
|
|
108
108
|
await StreamUtil.writeToFile(stream, out);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
return fs.
|
|
111
|
+
return fs.readFile(out);
|
|
112
112
|
}
|
|
113
113
|
}
|