pixelgeneratehttps://api.pixlab.io/pixelgenerate
Description
Generates a set of random pixels. This endpoint is similar to newimage except that the image contents is filled with random pixels. This is very useful for generating background (negative) samples for feeding Machine Learning training algorithms.
HTTP Methods
GET
Request Parameters
Required
Fields | Type | Description |
---|---|---|
width | Integer | Desired Image width. If this field is missing, then the height parameter is applied for this one. |
height | Integer | Desired Image height. If this field is missing, then the width parameter is applied for this one. |
key | String | Your PixLab API Key. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to. |
Optional
Fields | Type | Description |
---|---|---|
blob | Boolean | By default, this endpoint return a JSON object holding the link to the generated image output. But, if this parameter is set to true then the image binary contents is returned instead. |
color | String | Desired background color such as white, green, etc . If this field is missing, then the default background color is none. If you want a transparent image, then put tr instead. You can also set a color code like #cef48e if you want to. |
export | Format | Output image format. The default is PNG. Otherwise, pass JPEG, BMP, etc. at request. |
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:
Fields | Type | Description |
---|---|---|
status | Integer | Status code 200 indicates success, any other code indicates failure. |
link | URL | Link 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). |
id | String | Unique media ID. |
error | String | Error message if status != 200. |
Python Example
import requests
import json
# Generates a set of random pixels. This endpoint is similar to /newimage except that the image contents is filled with random pixels. This is very useful for generating background (negative) samples for feeding Machine Learning training algorithms
req = requests.get('https://api.pixlab.io/pixelgenerate',params={
'key':'PIXLAB_API_KEY',
"width":300,
"height":300
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
exit();
#Link to the newly generated image
print ("Randomly generated image location: "+ reply['ssl_link'])
See Also
newimage nsfw, sfw, ocr, facedetect, facelandmarks, grayscale, rotate, crop, tagimg, mogrify, blur, facecompare, facelookup