Cartoon Selfie
Turn your portrait into cartoon selfie automatically using the magic of Artificial Intelligence.
API Mode 1 : Return binary stream
Cartoon Selfie API Call Sample Code
curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
-F 'file=@/path/to/file.jpg' \
-f 'https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1' \
-o out.png
import requests
response = requests.post(
'https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1',
files={'file': open('/path/to/file.jpg', 'rb')},
headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
)
with open('out.png', 'wb') as out:
out.write(response.content)
$client = new GuzzleHttp\Client();
$res = $client->post('https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1', [
'multipart' => [
[
'name' => 'file',
'contents' => fopen('/path/to/file.jpg', 'r')
]
],
'headers' => [
'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
]
]);
$fp = fopen("out.png", "wb");
fwrite($fp, $res->getBody());
fclose($fp);
@Autowired
private RestTemplate restTemplate;
File file = new File("/path/to/file.jpg");
byte[] bytesArray = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(bytesArray); //read file into bytes[]
fis.close();
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("file",bytesArray,MediaType.IMAGE_JPEG);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.add("APIKEY","INSERT_YOUR_API_KEY_HERE");
HttpEntity<MultiValueMap> request= new HttpEntity<>(builder.build(),headers);
entity = restTemplate.postForEntity("https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1", request, Resource.class);
//todo: your logic to deal with entity
var request = require('request');
var fs = require('fs');
request.post({
url: 'https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1',
formData: {
file: fs.createReadStream('/path/to/file.jpg')
},
headers: {
'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
},
encoding: null
}, function(error, response, body) {
// console.log(response);
});
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
formData.Headers.Add("APIKEY", "INSERT_YOUR_API_KEY_HERE");
formData.Add(new ByteArrayContent(File.ReadAllBytes("/path/to/file.jpg")), "file", "file.jpg");
var response = client.PostAsync("https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1", formData).Result;
if(response.IsSuccessStatusCode) {
//todo: Handle your logic
} else {
//todo: Handle your logic
}
}
NSURL *fileUrl = [NSBundle.mainBundle URLForResource:@"file" withExtension:@"jpg"];
NSData *data = [NSData dataWithContentsOfURL:fileUrl];
if (!data) {
return;
}
AFHTTPSessionManager *manager =
[[AFHTTPSessionManager alloc] initWithSessionConfiguration:
NSURLSessionConfiguration.defaultSessionConfiguration];
manager.responseSerializer = [AFImageResponseSerializer serializer];
[manager.requestSerializer setValue:@"INSERT_YOUR_API_KEY_HERE"
forHTTPHeaderField:@"APIKEY"];
NSURLSessionDataTask *dataTask = [manager
POST:@"https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1"
parameters:nil
constructingBodyWithBlock:^(id _Nonnull formData) {
[formData appendPartWithFileData:data
name:@"file"
fileName:@"file.jpg"
mimeType:@"image/jpeg"];
}
progress:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// Handle your logic
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// Handle your logic
}];
[dataTask resume];
API documentation
Interface description
User requests to obtain the cartoon face of the main character in the input picture, and the server returns the image of the cartoon avatar.
Request description
-
Request URL: https://www.cutout.pro/api/v1/cartoonSelfie?cartoonType=1
-
Request method: POST
-
Return type: PNG image
-
Content-Type: multipart/form-data
Input parameters:
(1) Request parameters (Header)
Parameter | Parameter Type | Description |
---|---|---|
Content-Type | string | multipart/form-data |
APIKEY | string | Your API Key |
(2) Request parameters (Body)
Parameter | Description | Required |
---|---|---|
file | Picture file | Yes |
(3) Query string parameters
Parameter | Description | Required |
---|---|---|
cartoonType | Cartoon type, the value can be 0,1,2,3,4,5,6,7,8,9,10,11_header,11_full,12_header,12_full,13_header,13_full | Yes |
outputFormat | Output image format, currently supported: png, webp, jpg, jpeg | No |
Response description
- Normal return
Return an image with the cartoon face, in binary format and the content-type is image/png.
- Error return
if any error occurs, the response will be in json format.
{
"code": 1001, //
"data": null
"msg": 'Insufficient balance',
"time": 1590462453264
}
API Mode 2: Return base64 encoded string
Cartoon Selfie API Call Sample Code
curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
-F 'file=@/path/to/file.jpg' \
-f 'https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1'
import requests
response = requests.post(
'https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1',
files={'file': open('/path/to/file.jpg', 'rb')},
headers={'APIKEY': 'INSERT_YOUR_API_KEY_HERE'},
)
$client = new GuzzleHttp\Client();
$res = $client->post('https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1, [
'multipart' => [
[
'name' => 'file',
'contents' => fopen('/path/to/file.jpg', 'r')
]
],
'headers' => [
'APIKEY' => 'INSERT_YOUR_API_KEY_HERE'
]
]);
@Autowired
private RestTemplate restTemplate;
FileSystemResource resource = new FileSystemResource(new File("/path/to/file.jpg"));
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("file",resource,MediaType.IMAGE_JPEG);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.add("APIKEY","INSERT_YOUR_API_KEY_HERE");
HttpEntity<MultiValueMap> request= new HttpEntity(builder.build(),headers);
Resource entity = restTemplate.postForObject("https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1", request, Resource.class);
//todo: your logic to deal with entity
var request = require('request');
var fs = require('fs');
request.post({
url: 'https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1',
formData: {
file: fs.createReadStream('/path/to/file.jpg')
},
headers: {
'APIKEY': 'INSERT_YOUR_API_KEY_HERE'
},
encoding: null
}, function(error, response, body) {
// console.log(response);
});
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
formData.Headers.Add("APIKEY", "INSERT_YOUR_API_KEY_HERE");
formData.Add(new ByteArrayContent(File.ReadAllBytes("/path/to/file.jpg")), "file", "file.jpg");
var response = client.PostAsync("https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1", formData).Result;
if(response.IsSuccessStatusCode) {
//todo: Handle your logic
} else {
//todo: Handle your logic
}
}
NSURL *fileUrl = [NSBundle.mainBundle URLForResource:@"file" withExtension:@"jpg"];
NSData *data = [NSData dataWithContentsOfURL:fileUrl];
if (!data) {
return;
}
AFHTTPSessionManager *manager =
[[AFHTTPSessionManager alloc] initWithSessionConfiguration:
NSURLSessionConfiguration.defaultSessionConfiguration];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:@"INSERT_YOUR_API_KEY_HERE"
forHTTPHeaderField:@"APIKEY"];
NSURLSessionDataTask *dataTask = [manager
POST:@"https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1"
parameters:nil
constructingBodyWithBlock:^(id _Nonnull formData) {
[formData appendPartWithFileData:data
name:@"file"
fileName:@"file.jpg"
mimeType:@"image/jpeg"];
}
progress:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// Handle your logic
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// Handle your logic
}];
[dataTask resume];
API documentation
Interface description
User requests to obtain the cartoon face of the main character in the input picture, and the server returns the base64 encoded string of the corresponding cartoon avatar image.
Request description
-
Request URL: https://www.cutout.pro/api/v1/cartoonSelfie2?cartoonType=1
-
Request method: POST
-
Return type: PNG image
-
Content-Type: multipart/form-data
Input parameters:
(1) Request parameters (Header)
Parameter | Parameter Type | Description |
---|---|---|
Content-Type | string | multipart/form-data |
APIKEY | string | Your API Key |
(2) Request parameters (Body)
Parameter | Description | Required |
---|---|---|
file | Picture file | Yes |
(3) Query string parameters
Parameter | Description | Required |
---|---|---|
cartoonType | Cartoon type, the value can be 0,1,2,3,4,5,6,7,8,9,10,11_header,11_full,12_header,12_full,13_header,13_full | Yes |
outputFormat | Output image format, currently supported: png, webp, jpg, jpeg | No |
Response description
- Normal return
{
"code": 0,
"data": {
"imageBase64": "iVBORw0KGgo..." //base64 encoded string of the cartoon image
},
"msg": null,
"time": 1590462453264
}
- Error return
if any error occurs, the response will be in json format.
{
"code": 1001, //
"data": null
"msg": 'Insufficient balance',
"time": 1590462453264
}
API Mode 3: Return base64 string via image URL
Cartoon Selfie API Call Sample Code
curl -X GET --header 'Accept: application/json' \
--header 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
'https://www.cutout.pro/api/v1/cartoonSelfieByUrl?cartoonType=1&url=https%3A%2F%2Fd38b044pevnwc9.cloudfront.net%2Fcutout-nuxt%2Fcartoon%2F1-large.jpeg'
API documentation
Interface description
User uploads a portrait picture, and the server returns base64 string of the corresponding cartoon avatar image.
Request description
-
Request URL: https://www.cutout.pro/api/v1/cartoonSelfieByUrl?cartoonType=1&url=xxxx
-
Request method: POST
-
Return type: application/json
Input parameters:
(1) Request parameters (Header)
Parameter | Parameter Type | Description |
---|---|---|
APIKEY | string | Your API Key |
(2) Query string parameters
Parameter | Description | Required |
---|---|---|
cartoonType | Cartoon type, the value can be 0,1,2,3,4,5,6,7,8,9,10,11_header,11_full,12_header,12_full,13_header,13_full | Yes |
url | The url address of the picture | Yes |
outputFormat | Output image format, currently supported: png, webp, jpg, jpeg | No |
Response description
- Normal return
{
"code": 0,
"data": {
"imageBase64": "iVBORw0KGgo..." //base64 encoded string of the cartoon image
},
"msg": null,
"time": 1590462453264
}
- Error return
if any error occurs, the response will be in json format.
{
"code": 1001, //
"data": null
"msg": 'Insufficient balance',
"time": 1590462453264
}
Cartoon type sample images
Types 0,1,2,3,4,5,6,7,8,9,10,11_header,11_full,12_header,12_full,13_header,13_full are just to cartoonize the avatar. Type 5,10 is to cartoonize the overall picture.
-
0: Magic Mirror Avatar
-
1: Fairy Avatar
-
2: Dreamland Avatar
-
3: Manga Avatar
-
4: K-POP Avatar
-
5: K-POP
-
6: Pixel
-
7: Smile Avatar
-
8: Magic Mirror
-
9: American Comic Avatar
-
10: American Comic
-
11_header: Pixar Avatar
-
11_full: Pixar
-
12_header: Pinky Avatar
-
12_full: Pinky
-
13_header:
-
13_full:
Frequently asked questions
- Q: What are the requirements for the input image format?
- A: Support PNG, JPG, JPEG, BMP, WEBP
- Q: Is there a limit to the supported image size?
- A: The maximum resolution uploaded at present is 4096x4096 pixels, and the image file size is less than 15MB
- Q: Request QPS limit?
- A: Supports 5 simultaneous requests per second