REST Editing API
Overview
Pixo’s Image Editing API allows you to manipulate images by sending them together with a changes payload to a REST endpoint. This API implements most of the features of Pixo Editor and guarantees you the same results as if they were edited with the front-end Editor.
API endpoint
https://pixoeditor.com/api/image
Methods
GET https://pixoeditor.com/api/image/<JSON payload>
POST https://pixoeditor.com/api/image/<JSON payload>
POST https://pixoeditor.com/api/image --body <JSON payload>
Response
HTTP Status 200 and body containing the modified binary image.
HTTP Status 4xx in case of invalid input + JSON object in the response body containing the error message.
HTTP Status 5xx in case of server error + JSON object in the response body containing the error message.
Payload
Request payload must be a JSON object providing source of the edited image + modifications that should be applied to it.
- apikey
StringYour API key. IMPORTANT! Make sure that you protect your API key from your Control Panel by white-listing the IP address(es) of your server(s)! - src
Stringbase64-encoded source image or URL to the source image; required when the request content-type isapplication/json - image Binary source image; required when the request content-type is
multipart/form-data - output
ObjectSettings for output image’s quality and format. See the Output Object structure - filter
StringSee list of available filters - text
ArrayofObjects See the Text Object structure - stickers
ArrayofObjects See the Stickers Object structure - crop
ObjectSee the Crop Object structure - rotate
NumberRotation of the image in º . Valid values are90,180,270 - flip
StringFlip of the image horizontally or vertically. Valid values are"hor"and"ver" - adjust
ObjectSee the Color Adjustments Object structure - shape
StringSee list of available shapes - frame
NumberFrame index of the image frame to be applied - background
ObjectSee Background Object structure
Examples
The easiest way to test the REST Editing API is to open the below link in your web browser, just replace yourapikey with your real API key:
Or you can try the following cURL commands (just replace yourapikey with your real API key and input.jpeg with path to real image file on your computer:
curl -X POST -F 'apikey=yourapikey' -F 'filter=Sepia' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
curl -X POST -F 'apikey=yourapikey' -F 'text=[{"text":"Hello"},{"text":"world","position":"top-right"}]' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
curl -X POST -H "Content-Type: application/json" -d '{"apikey":"yourapikey","filter":"Sepia","src":"'$(base64 -i input.jpg)'"}' https://pixoeditor.com/api/image > output.jpg
Modifications
Output
curl -X POST -F 'apikey=yourapikey' -F 'filter=Sepia' -F 'output={"format":"png"}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
- format (String) Image format (type), can be one of the following:
"auto"Default Detects output format by smart image analysis (transparency (alpha), number of colors, gradients, and more) and determines the best format (png or jpeg) in terms of alpha, higher quality and lower filesize"input"Preserves the input format, but only in case it is jpeg or png. For any other format, the above behavior is applied"jpeg"Forces jpeg format. Note: transparent pixels will appear black"png"Forces png format. Note: output image may become very large (megabytes)"webp"Forces webp format.
- quality (Number) Value between 0 and 1, closer value to 1 results in higher quality, and vice-versa. Applies only if the output format is jpeg or webp. Default
0.65 - optimize (Boolean) Image compression by TinyPNG. Optimizing images will result in less KB (optimzied filesize) as well as slower image export. Default
false
Filter
curl -X POST -F 'apikey=yourapikey' -F 'filter=Sepia' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
List of available filters:
- Natural
- Amarok
- Klarendon
- Larc
- Mayfare
- Autumn
- Nightfall
- Sepia
- Grayscale
- BlackWhite
- Brownie
- Vintage
- Kodachrome
- Technicolor
- Polaroid
- Reddish
- Redify
- Convolute-Sharpen
- Convolute-ExtraSharp
- Convolute-Light
- Convolute-Dark
- Convolute-Blur
- Convolute-Emboss
- Invert
- Distressed
Text
curl -X POST -F 'apikey=yourapikey' -F 'text=[{"text":"hello, world!"}]' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
Array of Objects, each having the following shape and possible values:- text
Stringthe text message to insert - position (optional)
StringorObjectwith the following possible values:"top""top-left""top-right""left""center""right""bottom""bottom-left""bottom-right"Objectwith the following shape:- left
NumberThe desired left boundary of the sticker image in pixels - top
NumberThe desired top boundary of the sticker image in pixels
- left
- offset
Object(optional) with the following shape:- x
NumberThe desired horizontal offset in pixels (when larger than1) or % of edited image’s width - y
NumberThe desired vertical offset in pixels (when larger than1) or % of edited image’s height
- x
- width
Number(optional) The desired width of the text box. If the value is greater than1the width is set in pixels; otherwise it would be considered as a % of the edited image’s width, e.g.0.65= 65% of the edited image’s width. If not provided the width of the text box will be as big as the text inside. - height
Number(optional) The desired height of the text box. If the value is greater than1the height is set in pixels; otherwise it would be considered as a % of the edited image’s height, e.g.0.65= 65% of the edited image’s height. If not provided the height of the text box will be as big as the text inside. - fontFamily
String(optional) one of the following:- Arial
- Verdana
- Times New Roman
- Georgia
- Comic Sans MS
- Pacifico
- Roboto Condensed
- Oswald
- PT Sans
- Open Sans Condensed
- Ubuntu
- PT Sans Narrow
- Lobster
- Yanone Kaffeesatz
- Play
- Amatic SC
- Comfortaa
- Poiret One
- Russo One
- Philosopher
- Caveat
- Jura
- Marck Script
- Bad Script
- Montserrat Alternates
- Neucha
- Press Start 2P
- Pattaya
- fontSize
Number(optional) from10to100 - lineHeight
Number(optional) from-50to50 - charSpacing (optional)
Number - fontWeight
String(optional) one of the following:- normal
- bold
- fontStyle
String(optional) one of the following:- normal
- italic
- underline (optional)
Boolean - linethrough (optional)
Boolean - superscript (optional)
Boolean - subscript (optional)
Boolean - fill
String(optional) any valid CSS color (incl. rgba) - textShadowColor (optional)
Stringany valid CSS color (incl. rgba) - textShadowOffsetX (optional)
Numberfrom-20to20 - textShadowOffsetY (optional)
Numberfrom-20to20 - textShadowBlur (optional)
Numberfrom0to12 - strokeWidth (optional)
Numberfrom0to12 - textBackgroundColor (optional)
Stringany valid CSS color (incl. rgba) - backgroundColor
Stringany valid CSS color (incl. rgba)
Stickers
curl -X POST -F 'apikey=yourapikey' -F 'stickers=[{"src":"https://yourdomain.com/path/to/image.png"}]' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
Array of Objects each having the following structure:
- src
StringThe URL of the sticker image to be inserted - width
Number(optional) The desired width of the sticker image. If the value is greater than1the width is set in pixels; otherwise it would be considered as a % of the edited image’s width, e.g.0.65= 65% of the edited image’s width. If not provided the natural width of the sticker image would be used unless larger than the edited image’s width. - height
Number(optional) The desired height of the sticker image. If the value is greater than1the height is set in pixels; otherwise it would be considered as a % of the edited image’s height, e.g.0.65= 65% of the edited image’s height. If not provided the natural height of the sticker image would be used unless larger than the edited image’s height. - position (optional)
StringorObjectwith the following possible values:"top""top-left""top-right""left""center""right""bottom""bottom-left""bottom-right"Objectwith the following shape:- left
NumberThe desired left boundary of the sticker image in pixels - top
NumberThe desired top boundary of the sticker image in pixels
- left
- offset
Object(optional) with the following shape:- x
NumberThe desired horizontal offset in pixels (when larger than1) or % of edited image’s width - y
NumberThe desired vertical offset in pixels (when larger than1) or % of edited image’s height
- x
Crop
curl -X POST -F 'apikey=yourapikey' -F 'crop={"ratio":1.5}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
curl -X POST -F 'apikey=yourapikey' -F 'crop={"left":10,"top":10,"width":200,"height":200}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
curl -X POST -F 'apikey=yourapikey' -F 'crop={"type":"face"}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
The crop object has the following shape:
- ratio
NumberCrops the image with specific crop aspect ratio
or
- left
NumberLeft boundary in pixels - top
NumberTop boundary in pixels - width
NumberWidth in pixels - top
NumberHeight in pixels
or
- type
Stringhaving one of the following values:
"face": performs a face detection and crops the face if detected
- buffer
Numberbuffer added to the crop
Color Adjustments
curl -X POST -F 'apikey=yourapikey' -F 'adjust={"brightness":0.2}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
- brightness:
-1to1 - contrast:
-1to1 - hue-rotation:
-2to2 - saturation:
-1to1 - gamma-red:
0.01to2.2 - gamma-green:
0.01to2.2 - gamma-blue:
0.01to2.2 - blur:
0to1 - noise:
0to1000 - pixelate:
2to20
Shapes
curl -X POST -F 'apikey=yourapikey' -F 'shape=circle' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
List of available shapes:
- rhombus
- circle
- ellipse
- diamond
- star
- hexagon
- octagon
Background
curl -X POST -F 'apikey=yourapikey' -F 'background={"type":"transparent"}' -F '[email protected]' https://pixoeditor.com/api/image > output.jpeg
The background object has the following shape:
- type
StringThe type of the background with one of the following values:"transparent""solidcolor""replacement"
- bgcolor
StringCSS Color (rgba supported) for the new background. Applicable only if thetypeis"solidcolor" - src
StringURL (could be also dataurl or base64) of the replacement background image. Applicable only if thetypeis"replacement"