Image modifications in Direktiv
This app can run multiple Image Magick commands. The results can either be stored in the output folder of Direktiv to store them as variables or returned as base64.
functions:
- id: image-magick
image: direktiv/image-magick
type: knative-workflow
- id: img
type: action
action:
function: image-magick
input:
commands:
- convert mypic.png json:
- convert mypic.png -fuzz 25% -fill red -opaque white -flatten mypic.png
- convert mypic.png -resize 200x100 mypic.jpg
return:
- mypic.png
- id: set
type: setter
variables:
- key: mypic.png
scope: workflow
mimeType: application/octet-stream
value: iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAH0lEQVR42mNk+P+/noGKgHHUwFEDRw0cNXDUwJFqIAAczzHZPJWe1QAAAABJRU5ErkJggg==
transition: modify
- id: modify
type: action
action:
function: image
files:
- key: mypic.png
scope: workflow
input:
commands:
# stores the image in workflow scope variable `resized.png`
- convert mypic.png -resize 200% out/workflow/resized.png
Response contains the results of the command and the requested images as base64.
[
{
"result": "",
"success": true
}
]
[
{
"result": "iVBORw0KGgoAAAANSUhE...lFTkSuQmCC",
"success": true
}
]
| Type | Description |
|---|---|
| io.direktiv.command.error | Command execution failed |
| io.direktiv.output.error | Template error for output generation of the service |
| io.direktiv.ri.error | Can not create information object from request |
Properties
| Name | Type | Go type | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
| commands | []PostOKBodyCommandsItems | []*PostOKBodyCommandsItems | List of results for the commands. | |||
| images | []PostOKBodyImagesItems | []*PostOKBodyImagesItems | List of base64 encoded images. |
Properties
| Name | Type | Go type | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
| result | interface{} | interface{} | Empty for conversion commands and JSON for json returning commands. | {"image":{"alpha":"sss"}} | ||
| success | boolean | bool | Indicates success | true |
Properties
| Name | Type | Go type | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
| result | string | string | Base64 encoded image string | iVBORw0KGgoA...AABJRU5ErkJggg== | ||
| success | boolean | bool | Indicates success | true |
Properties
| Name | Type | Go type | Required | Default | Description | Example |
|---|---|---|---|---|---|---|
| commands | []string | []string | ✓ | List of commands to run | convert mypic.png -resize 200x100 mypic.jpg | |
| return | []string | []string | Returns the images as base64 | myimage.jpg |
Content type
Image
Digest
sha256:1ac23422e…
Size
126.6 MB
Last updated
about 4 years ago
docker pull westwind027/image-magick