imagemagickcloudconvert

Resizing image with ImageMagick and CloudConvert


I'm trying to upload image to CloudConvert, convert it to PNG and resize it with 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"
        }
    }
});

I'm trying it in snadbox, the file is uploaded correctly, converted to png, but resize returns: ERROR UNKNOWN_ERROR convert: no images defined '{OUTPUTFILE}' @ error/convert.c/ConvertImageCommand/3273. upload_thumbnail import/upload FINISHED

As there is no example or documentation how to pass parameters to the command, I'm stucked.

Thanks


Solution

  • In API v2, you need to specify paths like this:

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