mypiper commited on
Commit
ad8e561
·
verified ·
1 Parent(s): ca5712e

Update image_processing.yaml

Browse files
Files changed (1) hide show
  1. image_processing.yaml +60 -59
image_processing.yaml CHANGED
@@ -6,6 +6,57 @@ 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:
@@ -47,72 +98,22 @@ nodes:
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
 
6
  author: Anton Breslavskii | https://github.com/breslavsky
7
  url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/image_processing.yaml
8
  nodes:
9
+ random_image:
10
+ _id: random_image
11
+ arrange:
12
+ x: 80
13
+ y: 150
14
+ category:
15
+ id: process_images
16
+ title: en=Work with images;ru=Работа с изображениями
17
+ environment: {}
18
+ inputs:
19
+ width:
20
+ order: 1
21
+ title: en=Width;ru=Ширина
22
+ type: integer
23
+ required: true
24
+ placeholder: "200"
25
+ default: 200
26
+ height:
27
+ order: 2
28
+ title: en=Height;ru=Высота
29
+ type: integer
30
+ placeholder: "200"
31
+ default: 200
32
+ outputs:
33
+ image:
34
+ title: en=Image;ru=Изображение
35
+ type: image
36
+ package: image_processing
37
+ script: |-
38
+ export async function run({ inputs }) {
39
+ const { NextNode } = DEFINITIONS;
40
+ const {
41
+ width,
42
+ height
43
+ } = inputs;
44
+
45
+ const url = ['https://picsum.photos', width || 200];
46
+ if (!!height) {
47
+ url.push(height);
48
+ }
49
+
50
+ const { data: image } = await download(url.join('/'));
51
+ return NextNode.from({
52
+ outputs: {
53
+ image
54
+ }
55
+ });
56
+ }
57
+ source: catalog
58
+ title: en=Random image;ru=Случайная картинка
59
+ version: 1
60
  resize_image:
61
  _id: resize_image
62
  arrange:
 
98
  type: image
99
  package: image_processing
100
  script: |
101
+ export async function run({ inputs }) {
102
+ const { NextNode } = DEFINITIONS;
103
+ const sharp = require('sharp');
104
+ const { image, width, height, fit } = inputs;
105
 
106
+ const { data } = await download(image);
107
+ const resized = await sharp(data)
108
  .resize({
109
+ width,
110
  height,
111
  fit
112
  })
113
  .toBuffer();
114
 
115
+ return NextNode.from({ outputs: { image: resized } });
116
+ }
117
  source: catalog
118
  title: en=Resize image;ru=Изменить размер картинки
119
  version: 1