File size: 3,039 Bytes
186d7ea 95ec01a 186d7ea 95ec01a 186d7ea 95ec01a 186d7ea ad8e561 95ec01a ad8e561 186d7ea 95ec01a 186d7ea ad8e561 186d7ea ad8e561 186d7ea ad8e561 186d7ea ad8e561 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 120 |
_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
|