Oyyi

Oil Painting Effect

Transform photos into oil painting-like images with adjustable brush size and detail level.

POST /api/image/oil-paint

Request Parameters

ParameterTypeRequiredDescription
fileFileYesThe image file to process. Supported formats: JPEG, PNG, WebP, BMP, TIFF.
radiusIntegerNoThe radius of the brush effect. Higher values create a more pronounced painting effect. Range: 1-10. Default: 4.
intensity_levelsIntegerNoNumber of intensity levels. Higher values create more distinct color regions. Range: 1-20. Default: 20.

Response

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

Example Request

    // example.sh
curl -X POST "https://oyyi.xyz/api/image/oil-paint"   -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@image.jpg" \
  -F "radius=4" \
  -F "intensity_levels=20" \
  --output oil_painting.jpg
  

Example with Python

    // oil_painting.py
import requests

url = "https://oyyi.xyz/api/image/oil-paint"

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

data = {
    'radius': 4,
    'intensity_levels': 20
}

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

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

Example with JavaScript

    // oil_painting.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('radius', '4');
formData.append('intensity_levels', '20');

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

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

Painting Styles

Standard

Classic oil painting effect with balanced brush strokes and color regions. Good for most images.

Impressionist

Inspired by impressionist paintings with smaller brush strokes and more emphasis on light and color.

Expressionist

Bold, exaggerated style with stronger brush strokes and more vivid colors.

How It Works

The oil painting effect simulates the appearance of an oil painting through a combination of techniques:

  1. Neighborhood Analysis: For each pixel, the algorithm examines a neighborhood of pixels (determined by the radius parameter).
  2. Color Quantization: Within each neighborhood, colors are grouped into bins (determined by the intensity parameter).
  3. Dominant Color Selection: The most frequent color in each neighborhood is selected to replace the center pixel.
  4. Style Adjustments: Different styles apply variations to this process, such as different neighborhood shapes or color weighting.

The result is an image that appears to be composed of small brush strokes with simplified color regions, similar to an oil painting.

Parameter Effects

Radius

  • Small (1-3): Fine brush strokes, more detail preserved
  • Medium (4-6): Balanced brush size, good for most images
  • Large (7-10): Large brush strokes, more abstract appearance

Intensity

  • Low (1-5): Subtle effect, more colors preserved
  • Medium (6-12): Moderate color simplification
  • High (13-20): Strong color quantization, fewer distinct colors

Error Responses

Status CodeDescription
400Bad request. Missing required parameters, invalid radius value, invalid 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 oil painting effect works best on images with clear subjects and relatively simple compositions.
  • Images with fine details may lose some of those details when the effect is applied, especially with larger radius values.
  • Landscapes, portraits, and still life images typically produce good results with this effect.
  • 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 and radius value due to the computational complexity of the effect.

Use Cases

  • Creating artistic renditions of photographs
  • Transforming photos for use in digital art or mixed media projects
  • Generating painting-like images for decorative purposes
  • Creating unique profile pictures or social media content
  • Preparing images for printing on canvas
  • Educational demonstrations of different painting styles
  • Creating visual assets for games or applications with a painted aesthetic