Skip to main content

Image

An image item places a raster image on the project map. Image creation requires a multipart file upload.

Item type: image

Properties

PropertyTypeRequiredUpdatableDefaultDescription
positionobjectNoYes{ x: 0, y: 0 }Position with x and y fields.
sizeobjectYesYesSize with width and height fields. Min 5 per dimension.
scalenumberNoYes1Scale factor. Must be > 0.
anglenumberNoYes0Rotation angle (0360).
fileNamestringYesYesOriginal file name. Max 128 characters, no path separators (/, \).
mimeTypestringYesYesMIME type of the file. See Supported MIME Types.
fileSizenumberYesYesFile size in bytes.
info

When using the file upload endpoint, fileName, mimeType, and fileSize are automatically populated from the uploaded file. You only need to set them explicitly when using the JSON-only endpoint.

Supported MIME Types

MIME TypeFormat
image/jpegJPEG
image/pngPNG
image/gifGIF
image/webpWebP

Create (File Upload)

Creates a new image item with file upload. This is the recommended method.

POST /api/v2/projects/{projectId}/item/{parent}/image/file
Content-Type: multipart/form-data

The request must be sent as multipart/form-data with two parts:

  • dataobject: JSON string with the item properties.
  • binary: The image file.

curl

curl -X POST "https://api.deon.cloud/api/v2/projects/{projectId}/item/inbox/image/file" \
-H "Authorization: Bearer <token>" \
-F 'dataobject={
"position": { "x": 100, "y": 200 },
"size": { "width": 400, "height": 300 }
}' \
-F "binary=@/path/to/photo.jpg"

JavaScript

const formData = new FormData();

formData.append(
"dataobject",
JSON.stringify({
position: { x: 100, y: 200 },
size: { width: 400, height: 300 },
})
);

formData.append("binary", fileInput.files[0]);

const response = await fetch(
`https://api.deon.cloud/api/v2/projects/${projectId}/item/inbox/image/file`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
},
body: formData,
}
);

const data = await response.json();
console.log(data.itemId);

Response

{
"itemId": "e5f6a7b8-c9d0-1234-efab-345678901234"
}

Update

Updates an existing image item's properties. File content cannot be changed via update.

PATCH /api/v2/projects/{projectId}/item/image/{itemId}

curl

curl -X PATCH "https://api.deon.cloud/api/v2/projects/{projectId}/item/image/{itemId}" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"position": { "x": 200, "y": 400 },
"size": { "width": 600, "height": 450 }
}'

JavaScript

const response = await fetch(
`https://api.deon.cloud/api/v2/projects/${projectId}/item/image/${itemId}`,
{
method: "PATCH",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
position: { x: 200, y: 400 },
size: { width: 600, height: 450 },
}),
}
);

const data = await response.json();
console.log(data.itemId);

Response

{
"itemId": "e5f6a7b8-c9d0-1234-efab-345678901234"
}