check
This command allows you to make treatments according to the mimetype of the file.
see also test (filter)
parameters
mimetype: the mimetype selector
It could be a single string or an array of strings (meaning an or with each string) : the value is the wanted mimetype, or the beginning of the mimetype.
Examples:“mimetype": "image/jpeg”
: select JPEG images“mimetype": “image/”
: select any images (those whose mimetype begins with “image/”).“mimetype": [”image/jpeg”,”image/png”]:
select JPEG images and PNG images
if: action to do if file mimetype matches selector
else: action to do if file mimetype doen’t match selector
Action can be:
null: means cancel transform execution (do not return any image)
json object or json array: a command set to apply
empty json object or empty json array: continue process
JSON object properties
mimetype: the file mimetype selector
if: action to do file matches the selector
else: action to do file doesn’t match the selector
simplified syntax parameters
Not supported.
array type parameters
[mimetype]: if matches the mimetype, continue, else cancel
[mimetype, action]: if matches the mimetype, do the action, else cancel
[mimetype,actionIf,actionElse]: if matches the mimetype, do the actionIf, else do actionElse
string type parameter
Not supported.
Example 1
Transforms non-image files to jpeg before resizing.
{
"check": {
"mimetypes": "image/",
"if": {},
"else": {
"format": "jpg"
}
},
"resize": [
400,
400
]
}
Example 2
Resize a file only if it's an image (else do nothing)
{
"check": {
"mimetypes": "image/",
"if": {},
"else": null
},
"resize": [
400,
400
]
}