@travetto/image 3.0.0-rc.7 → 3.0.0-rc.9
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/README.md +1 -1
- package/package.json +3 -3
- package/src/convert.ts +4 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install @travetto/image
|
|
|
10
10
|
|
|
11
11
|
This module provides functionality for image resizing, and png optimization. This is primarily meant to be used in conjunction with other modules, like the [Asset](https://github.com/travetto/travetto/tree/main/module/asset#readme "Modular library for storing and retrieving binary assets") module or the [Email Templating](https://github.com/travetto/travetto/tree/main/module/email-template#readme "Email templating module") module. It can also be invoked directly as needed (as it can be very handy for batch processing images on the command line).
|
|
12
12
|
|
|
13
|
-
The utility's primary structure revolves around the [
|
|
13
|
+
The utility's primary structure revolves around the [CommandOperation](https://github.com/travetto/travetto/tree/main/module/command/src/command.ts#L11) from the [Command](https://github.com/travetto/travetto/tree/main/module/command#readme "Support for executing complex commands at runtime.") module. The [CommandOperation](https://github.com/travetto/travetto/tree/main/module/command/src/command.ts#L11) allows for declaration of a local executable, and a fall-back docker container (mainly meant for development). The [ImageConverter](https://github.com/travetto/travetto/tree/main/module/image/src/convert.ts#L31) utilizes [ImageMagick](https://imagemagick.org/index.php), [pngquant](https://pngquant.org/), and [Jpegoptim](https://github.com/tjko/jpegoptim) as the backing for image resizing and png compression, respectively.
|
|
14
14
|
|
|
15
15
|
**Code: Simple Image Resize**
|
|
16
16
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/image",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.9",
|
|
4
4
|
"description": "Image support, resizing, and optimization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"images",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"directory": "module/image"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/base": "^3.0.0-rc.
|
|
27
|
-
"@travetto/command": "^3.0.0-rc.
|
|
26
|
+
"@travetto/base": "^3.0.0-rc.9",
|
|
27
|
+
"@travetto/command": "^3.0.0-rc.9"
|
|
28
28
|
},
|
|
29
29
|
"travetto": {
|
|
30
30
|
"displayName": "Image"
|
package/src/convert.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { CommandOperation } from '@travetto/command';
|
|
5
5
|
import { StreamUtil } from '@travetto/base';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -33,7 +33,7 @@ export class ImageConverter {
|
|
|
33
33
|
/**
|
|
34
34
|
* Resize/conversion util
|
|
35
35
|
*/
|
|
36
|
-
static CONVERTER = new
|
|
36
|
+
static CONVERTER = new CommandOperation({
|
|
37
37
|
containerImage: ' jameskyburz/graphicsmagick-alpine:v1.0.0',
|
|
38
38
|
localCheck: ['gm', ['-version']]
|
|
39
39
|
});
|
|
@@ -41,7 +41,7 @@ export class ImageConverter {
|
|
|
41
41
|
/**
|
|
42
42
|
* Compressor
|
|
43
43
|
*/
|
|
44
|
-
static PNG_COMPRESSOR = new
|
|
44
|
+
static PNG_COMPRESSOR = new CommandOperation({
|
|
45
45
|
containerImage: 'agregad/pngquant',
|
|
46
46
|
localCheck: ['pngquant', ['-h']]
|
|
47
47
|
});
|
|
@@ -49,7 +49,7 @@ export class ImageConverter {
|
|
|
49
49
|
/**
|
|
50
50
|
* Compressor
|
|
51
51
|
*/
|
|
52
|
-
static JPEG_COMPRESSOR = new
|
|
52
|
+
static JPEG_COMPRESSOR = new CommandOperation({
|
|
53
53
|
containerImage: 'shomatan/jpegoptim:1.4.4',
|
|
54
54
|
localCheck: ['jpegoptim', ['-h']]
|
|
55
55
|
});
|