Oyyi

Cartoon Effect

Transform photos into cartoon-style images with adjustable parameters.

POST /api/image/cartoon

Request Parameters

ParameterTypeRequiredDescription
fileFileYesThe image file to process. Supported formats: JPEG, PNG, WebP, BMP, TIFF.
edge_sizeIntegerNoSize of edges (1-5). Higher values create thicker edges. Default: 1.
num_colorsIntegerNoNumber of colors (2-16). Lower values create more cartoon-like appearance. Default: 8.

Response

Returns the cartoon-style image in the same format as the input file.

Example Request

    // example.sh
curl -X POST "https://oyyi.xyz/api/image/cartoon"   -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@image.jpg" \
  -F "edge_size=1" \
  -F "num_colors=8" \
  --output cartoon.jpg
  

Example with Python

    // cartoon.py
import requests

url = "https://oyyi.xyz/api/image/cartoon"

files = {
    'file': open('image.jpg', 'rb')
}

data = {
    'edge_size': 1,
    'num_colors': 8
}

response = requests.post(url, files=files, data=data)

# Save the cartoon image
with open('cartoon.jpg', 'wb') as f:
    f.write(response.content)
  

Example with JavaScript

    // cartoon.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('edge_size', '1');
formData.append('num_colors', '8');

fetch('https://oyyi.xyz/api/image/cartoon', {
  method: 'POST',
  body: formData
})
.then(response => response.blob())
.then(blob => {
  // Create a URL for the blob
  const url = URL.createObjectURL(blob);

  // Create a link to download the image
  const a = document.createElement('a');
  a.href = url;
  a.download = 'cartoon.jpg';
  a.click();

  // Clean up by revoking the URL
  URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
  

Cartoon Styles

Standard

Classic cartoon look with simplified colors and defined edges. Good for most images.

Anime

Inspired by Japanese animation with more vibrant colors and stylized edges.

Comic

Resembles comic book art with stronger edges and more pronounced color blocks.

How It Works

The cartoon effect is created through a combination of edge detection and color quantization:

  1. Edge Detection: The algorithm identifies edges in the image using techniques similar to those in the edge-detection endpoint.
  2. Color Quantization: The colors in the image are simplified (reduced) to create flat areas of color typical in cartoons.
  3. Combination: The edges are overlaid on the simplified color image to create the final cartoon effect.

Different styles apply variations to this process, such as different edge detection methods or color palettes.

Parameter Effects

Strength

  • Low (1): Subtle effect, more realistic
  • Medium (2-3): Balanced cartoon look
  • High (4-5): Exaggerated cartoon effect with very simplified colors

Edge Intensity

  • Low (0.5-0.9): Subtle edges, softer look
  • Medium (1.0-1.9): Clear edges, classic cartoon style
  • High (2.0-3.0): Bold, pronounced edges

Error Responses

Status CodeDescription
400Bad request. Missing required parameters, invalid strength value, invalid edge_intensity value, invalid style, or invalid file format.
413Payload too large. The file size exceeds the maximum allowed limit.
500Internal server error. Something went wrong on the server.

Notes

  • The cartoon effect works best on images with clear subjects and relatively simple backgrounds.
  • Portraits and landscapes typically produce good results with the cartoon effect.
  • Images with very complex textures or patterns may not cartoonize as effectively.
  • The maximum file size allowed is 10MB.
  • This operation preserves the alpha channel (transparency) if present in the original image.
  • Processing time increases with image size due to the complexity of the effect.

Use Cases

  • Creating profile pictures with a cartoon style
  • Transforming photos for social media posts
  • Generating cartoon-style illustrations from photographs
  • Creating stylized images for presentations or marketing materials
  • Preparing images for comic or storyboard creation
  • Educational content to demonstrate artistic styles