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

      (async () => {
        const { image, width, height, fit } = inputs;

         const { data } = await download(image);
         const resized = await sharp(data)
              .resize({
                  width, 
                  height,
                  fit
              })
              .toBuffer();

        return next({outputs: { image: resized }});
      })();
    source: catalog
    title: en=Resize image;ru=Изменить размер картинки
    version: 1
  random_image:
    _id: random_image
    arrange:
      x: 80
      y: 150
    category:
      id: process_images
      title: en=Work with images;ru=Работа с изображениями
    environment: {}
    inputs:
      width:
        order: 1
        title: en=Width;ru=Ширина
        type: integer
        required: true
        placeholder: "200"
        default: 200
      height:
        order: 2
        title: en=Height;ru=Высота
        type: integer
        placeholder: "200"
        default: 200
    outputs:
      image:
        title: en=Image;ru=Изображение
        type: image
    package: image_processing
    script: |-
      (async () => {
          const {
              width,
              height
          } = inputs;

          const url = ['https://picsum.photos', width || 200];
          if (!!height) {
              url.push(height);
          }

          const { data: image } = await download(url.join('/'));
          return next({
              outputs: {
                  image
              }
          });
      })();
    source: catalog
    title: en=Random image;ru=Случайная картинка
    version: 1