Oyyi

Sketch Effect

Convert images to sketch-like drawings with various styles and adjustable parameters.

POST /api/image/sketch

Request Parameters

ParameterTypeRequiredDescription
fileFileYesThe image file to process. Supported formats: JPEG, PNG, WebP, BMP, TIFF.

Response

Returns the image with the sketch effect applied, in the same format as the input file.

Example Request

    // example.sh
curl -X POST "https://oyyi.xyz/api/image/sketch"   -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@image.jpg" \
  -F "style=pencil" \
  -F "intensity=0.8" \
  --output sketch.jpg
  

Example with Python

    // sketch.py
import requests

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

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

data = {
    'style': 'pencil',
    'intensity': 0.8
}

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

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

Example with JavaScript

    // sketch.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('style', 'pencil');
formData.append('intensity', '0.8');

fetch('https://oyyi.xyz/api/image/sketch', {
  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 = 'sketch.jpg';
  a.click();

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

Sketch Styles

Pencil

Creates a soft, graphite pencil-like effect with smooth gradients. Good for portraits and detailed images.

Charcoal

Creates a rougher, more textured sketch with higher contrast. Good for dramatic or moody images.

Pen

Creates a more defined, line-based sketch with sharper edges. Good for architectural or structural images.

How It Works

The sketch effect transforms a photo into a drawing-like image through several steps:

  1. Grayscale Conversion: The image is converted to grayscale to focus on tonal values.
  2. Edge Detection: Various edge detection algorithms are applied to identify the lines and contours in the image.
  3. Inversion: The result is inverted to create dark lines on a light background (unless the invert parameter is set to true).
  4. Style Application: Different filters and textures are applied based on the selected style.
  5. Background Integration: The sketch is combined with the specified background color.

The intensity parameter controls the strength of the edge detection and the contrast of the final result.

Intensity Examples

Low Intensity (0.1-0.3)

Subtle sketch effect, lighter lines

Medium Intensity (0.4-0.7)

Balanced sketch effect, good for most uses

High Intensity (0.8-1.0)

Strong sketch effect, darker lines and higher contrast

Error Responses

Status CodeDescription
400Bad request. Missing required parameters, invalid style, invalid intensity value, invalid background color, 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 sketch effect works best on images with clear subjects and good contrast.
  • Images with complex textures or very busy backgrounds may produce less clear sketch results.
  • The pencil style is generally the most versatile and works well for most images.
  • The charcoal style creates a more dramatic, high-contrast result that can be effective for landscapes or architectural images.
  • The pen style creates more defined lines and can be good for images with clear edges and structures.
  • The maximum file size allowed is 10MB.
  • This operation preserves the alpha channel (transparency) if present in the original image, but it may be less noticeable in the sketch result.

Use Cases

  • Creating artistic renditions of photographs
  • Generating sketch-like images for coloring or tracing
  • Creating unique profile pictures or social media content
  • Preparing reference images for artists
  • Creating illustrations for books or articles
  • Generating visual assets for design projects with a hand-drawn aesthetic
  • Converting photos to sketches for architectural or engineering visualization