Vignette Effect
Apply a vignette effect to images, darkening or coloring the edges while keeping the center bright.
/api/image/vignette
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to process. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
intensity | Float | No | The intensity of the vignette effect. Higher values create a more pronounced vignette. Range: 0.1-1.0. Default: 0.5 . |
Response
Returns the image with the vignette effect applied, in the same format as the input file.
Example Request
// example.sh
curl -X POST "https://oyyi.xyz/api/image/vignette" -H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg" \
-F "intensity=0.5" \
--output vignetted.jpg
Example with Python
// vignette.py
import requests
url = "https://oyyi.xyz/api/image/vignette"
files = {
'file': open('image.jpg', 'rb')
}
data = {
'intensity': 0.5
}
response = requests.post(url, files=files, data=data)
# Save the vignetted image
with open('vignetted.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// vignette.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('intensity', '0.5');
fetch('https://oyyi.xyz/api/image/vignette', {
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 = 'vignetted.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Vignette Shapes
Circle
Creates a circular vignette that darkens the corners of the image. This is the classic vignette effect and works well for most images.
Rectangle
Creates a rectangular vignette that darkens the edges of the image. This can be useful for images with a rectangular subject or to create a frame-like effect.
Common Vignette Colors
Black
Classic vignette, darkens the edges
White
Creates a fade-to-white effect at the edges
Custom Colors
Use any color name or hex code for creative effects
How It Works
The vignette effect creates a gradual darkening or coloring from the center of the image toward the edges:
- Mask Creation: The algorithm creates a mask based on the distance from each pixel to the center of the image.
- Gradient Application: This mask is used to apply a gradient that fades from transparent in the center to the specified color at the edges.
- Blending: The gradient is blended with the original image, with the intensity parameter controlling the strength of the effect.
The shape parameter determines whether the distance calculation is based on a circle (Euclidean distance) or a rectangle (Manhattan distance).
Intensity Examples
Low Intensity (0.1-0.3)
Subtle vignette, barely noticeable
Medium Intensity (0.4-0.6)
Moderate vignette, good for most uses
High Intensity (0.7-1.0)
Strong vignette, dramatic effect
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid intensity value, invalid color value, invalid shape, or invalid file format. |
413 | Payload too large. The file size exceeds the maximum allowed limit. |
500 | Internal server error. Something went wrong on the server. |
Notes
- The vignette effect is a classic photographic technique that was originally caused by optical limitations in camera lenses.
- A black vignette can help draw attention to the center of the image and create a more dramatic, moody atmosphere.
- A white vignette can create a dreamy, ethereal look, particularly for portraits or wedding photography.
- Colored vignettes can be used for creative effects or to complement the color scheme of the image.
- The maximum file size allowed is 10MB.
- This operation preserves the alpha channel (transparency) if present in the original image.
Use Cases
- Drawing attention to the subject in the center of the image
- Creating a vintage or retro look for photographs
- Adding mood or atmosphere to portraits
- Creating a frame-like effect without adding an actual border
- Reducing distractions at the edges of an image
- Creating artistic effects for social media posts
- Enhancing the depth and dimension of landscape photography