Team Ai
Modelpublic

PiperMy/Node-Packages

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
image_processing.yaml120 linesDownload Raw Back to root
1_id: image_processing2author: Anton Breslavskii | https://github.com/breslavsky3description: Change format, resize images, etc.4readme: The first version5title: en=Process images;ru=Обработка изображений6url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/image_processing.yaml7version: 28nodes:9  random_image:10    _id: random_image11    arrange:12      x: 8013      y: 15014    category:15      _id: process_images16      title: en=Work with images;ru=Работа с изображениями17    environment: {}18    inputs:19      width:20        order: 121        title: en=Width;ru=Ширина22        type: integer23        required: true24        placeholder: "200"25        default: 20026      height:27        order: 228        title: en=Height;ru=Высота29        type: integer30        placeholder: "200"31        default: 20032    outputs:33      image:34        title: en=Image;ru=Изображение35        type: image36    package: image_processing37    script: |-38      export async function run({ inputs }) {39          const { NextNode } = DEFINITIONS;40          const {41              width,42              height43          } = 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                  image54              }55          });56      }57    source: catalog58    title: en=Random image;ru=Случайная картинка59    version: 160  resize_image:61    _id: resize_image62    arrange:63      x: 41064      y: 15065    category:66      _id: process_images67      title: en=Work with images;ru=Работа с изображениями68    inputs:69      image:70        order: 171        title: Image72        type: image73        required: true74      width:75        order: 276        title: Width77        type: integer78        default: 20079      height:80        order: 381        title: Height82        type: integer83        default: 20084      fit:85        order: 486        title: Fit87        type: string88        default: cover89        enum:90          - cover|Cover91          - contain|Contain92          - fill|Fill93          - inside|Inside94          - outside|Outside95    outputs:96      image:97        title: Image98        type: image99    package: image_processing100    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                  fit112              })113              .toBuffer();114 115          return NextNode.from({ outputs: { image: resized } });116      }117    source: catalog118    title: en=Resize image;ru=Изменить размер картинки119    version: 1120