Version 1.9.72 (Release Notes)


drawpointshttps://api.pixlab.io/drawpoints

Description

Draw as much points as desired on a given input image.

HTTP Methods

POST

Request Parameters

Required

FieldsTypeDescription
imgURLInput image URL. If you want to upload your image directly from your app, call store before invoking this one.
pointsArrayJSON array holding the coordinates of the points to be drawn (See below).
keyStringYour PixLab API Key. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

Optional
FieldsTypeDescription
blobBooleanBy default, this command return a JSON object holding the link to the image output. But, if this parameter is set to true then the image binary contents is returned instead.
colorStringGlobal color for each point to be drawn which default to white. Use hex color code such as #cef45f if you want to.

POST Request Body

Allowed Content-Type:

application/json

Only JSON data is allowed. the field of interest here is the points parameter which must be a JSON array holding the object coordinates of each point to be drawn on the input image. The following are the required parameters for each object in the points array:
FieldsTypeDescription
xIntegerPoint's X coordinate.
yIntegerPoint's Y coordinate.
colorStringOptional Color to apply for this specific point which default to white. Use hex color code such as #cef45f if you want to.

So, a typical points array should look like this (See the example section for a working snippet).


points = [
{
x: 200,
y: 290
},
{
x: 165,
y: 95,
color: 'red'
}
]

Response

application/json if the optional blob parameter is not set.

This command return a JSON object after each call only if the optional blob parameter is not set. Otherwise the image binary contents is returned instead. The following are the JSON fields returned in response body:

FieldsTypeDescription
statusIntegerStatus code 200 indicates success, any other code indicates failure.
linkURLLink to the image output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard on how to do that).
idStringUnique image ID.
errorStringError message if status != 200.

Python Example

# Draw some points.
import requests
import json

req = requests.post('https://api.pixlab.io/drawpoints',headers={'Content-Type':'application/json'},data=json.dumps({
	'img': 'https://s3.amazonaws.com/pixlab.xyz/npi5873a69a18862.png',
	'key':'My_Key',
	'points': [
	{
		"x":164,
		"y":95
	},
	{
		"x":250,
		"y":180
	},
	{
		"x":140,
		"y":110,
		"color":"yellow"
	},
	{
		"x":160,
		"y":120
	},
	{
		"x":194,
		"y":130,
		"color":"green"
	},
	{
		"x":199,
		"y":100
	}
	]
}))
reply = req.json()
if reply['status'] != 200:
    print (reply['error'])
else:
    print ("Pic location: "+ reply['link'])

See Also