使用 ImageMagick 和 CloudConvert 调整图像大小

Resizing image with ImageMagick and CloudConvert

我正在尝试将图像上传到 CloudConvert,将其转换为 PNG 并使用 ImageMagick 调整其大小。

import CloudConvert from 'cloudconvert';

const cloudConvert = new CloudConvert('api_key');

let job = await cloudConvert.jobs.create({
    "tasks": {
        "upload_thumbnail": {
            "operation": "import/upload"
        },
        "convert_thumbnail": {
            "operation": "convert",
            "input": [
                "upload_thumbnail"
            ],
            "output_format": "png",
            "filename": "thumbnail.png"
        },
        "resize_2x_thumbnail": {
            "operation": "command",
            "engine": "imagemagick",
            "input": [
                "convert_thumbnail"
            ],
            "command": "convert",
            "arguments": "{INPUTFILE} -resize 330x330 {OUTPUTFILE}",
            "engine_version": "7.0.9"
        }
    }
});

我在 snadbox 中尝试,文件上传正确,转换为 png,但调整大小 returns: ERROR UNKNOWN_ERROR convert: no images defined '{OUTPUTFILE}' @ error/convert.c/ConvertImageCommand/3273. upload_thumbnail import/upload FINISHED

由于没有示例或文档说明如何将参数传递给命令,我被卡住了。

谢谢

在 API v2 中,您需要指定如下路径:

"arguments": "/input/convert_thumbnail/thumbnail.png -resize 330x330 /output/thumbnail.png"