mypiper commited on
Commit
186d7ea
·
verified ·
1 Parent(s): 78cfd34

Create image_processing.yaml

Browse files
Files changed (1) hide show
  1. image_processing.yaml +118 -0
image_processing.yaml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _id: image_processing
2
+ version: 1
3
+ title: en=Process images;ru=Обработка изображений
4
+ description: Change format, resize images, etc.
5
+ readme: The first version
6
+ author: Anton Breslavskii | https://github.com/breslavsky
7
+ url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/image_processing.yaml
8
+ nodes:
9
+ resize_image:
10
+ _id: resize_image
11
+ arrange:
12
+ x: 410
13
+ y: 150
14
+ category:
15
+ id: process_images
16
+ title: en=Work with images;ru=Работа с изображениями
17
+ inputs:
18
+ image:
19
+ order: 1
20
+ title: Image
21
+ type: image
22
+ required: true
23
+ width:
24
+ order: 2
25
+ title: Width
26
+ type: integer
27
+ default: 200
28
+ height:
29
+ order: 3
30
+ title: Height
31
+ type: integer
32
+ default: 200
33
+ fit:
34
+ order: 4
35
+ title: Fit
36
+ type: string
37
+ default: cover
38
+ enum:
39
+ - cover|Cover
40
+ - contain|Contain
41
+ - fill|Fill
42
+ - inside|Inside
43
+ - outside|Outside
44
+ outputs:
45
+ image:
46
+ title: Image
47
+ type: image
48
+ package: image_processing
49
+ script: |
50
+ const sharp = require('node_modules/sharp');
51
+
52
+ (async () => {
53
+ const { image, width, height, fit } = inputs;
54
+
55
+ const { data } = await download(image);
56
+ const resized = await sharp(data)
57
+ .resize({
58
+ width,
59
+ height,
60
+ fit
61
+ })
62
+ .toBuffer();
63
+
64
+ return next({outputs: { image: resized }});
65
+ })();
66
+ source: catalog
67
+ title: en=Resize image;ru=Изменить размер картинки
68
+ version: 1
69
+ random_image:
70
+ _id: random_image
71
+ arrange:
72
+ x: 80
73
+ y: 150
74
+ category:
75
+ id: process_images
76
+ title: en=Work with images;ru=Работа с изображениями
77
+ environment: {}
78
+ inputs:
79
+ width:
80
+ order: 1
81
+ title: en=Width;ru=Ширина
82
+ type: integer
83
+ required: true
84
+ placeholder: "200"
85
+ default: 200
86
+ height:
87
+ order: 2
88
+ title: en=Height;ru=Высота
89
+ type: integer
90
+ placeholder: "200"
91
+ default: 200
92
+ outputs:
93
+ image:
94
+ title: en=Image;ru=Изображение
95
+ type: image
96
+ package: image_processing
97
+ script: |-
98
+ (async () => {
99
+ const {
100
+ width,
101
+ height
102
+ } = inputs;
103
+
104
+ const url = ['https://picsum.photos', width || 200];
105
+ if (!!height) {
106
+ url.push(height);
107
+ }
108
+
109
+ const { data: image } = await download(url.join('/'));
110
+ return next({
111
+ outputs: {
112
+ image
113
+ }
114
+ });
115
+ })();
116
+ source: catalog
117
+ title: en=Random image;ru=Случайная картинка
118
+ version: 1