_id: image_processing author: Anton Breslavskii | https://github.com/breslavsky description: Change format, resize images, etc. readme: The first version title: en=Process images;ru=Обработка изображений url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/image_processing.yaml version: 2 nodes: 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: |- export async function run({ inputs }) { const { NextNode } = DEFINITIONS; const { width, height } = inputs; const url = ['https://picsum.photos', width || 200]; if (!!height) { url.push(height); } const { data: image } = await download(url.join('/')); return NextNode.from({ outputs: { image } }); } source: catalog title: en=Random image;ru=Случайная картинка version: 1 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: | export async function run({ inputs }) { const { NextNode } = DEFINITIONS; const sharp = require('sharp'); const { image, width, height, fit } = inputs; const { data } = await download(image); const resized = await sharp(data) .resize({ width, height, fit }) .toBuffer(); return NextNode.from({ outputs: { image: resized } }); } source: catalog title: en=Resize image;ru=Изменить размер картинки version: 1