Apply Blur
Apply a Gaussian blur effect to images with adjustable intensity.
/api/image/blur
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to blur. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
intensity | Integer | No | The blur intensity. Higher values create a stronger blur effect. Range: 1-50. Default: 5 . |
Response
Returns the blurred image in the same format as the input file.
Example Request
// example.sh
curl -X POST "https://oyyi.xyz/api/image/blur" -H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg" \
-F "intensity=5" \
--output blurred.jpg
Example with Python
// blur.py
import requests
url = "https://oyyi.xyz/api/image/blur"
files = {
'file': open('image.jpg', 'rb')
}
data = {
'intensity': 5
}
response = requests.post(url, files=files, data=data)
# Save the blurred image
with open('blurred.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// blur.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('intensity', '5');
fetch('https://oyyi.xyz/api/image/blur', {
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 = 'blurred.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Blur Methods
Gaussian
Creates a smooth, natural-looking blur by applying a Gaussian function. Best for most use cases.
Box
Applies a simple box blur that averages neighboring pixels. Faster but less smooth than Gaussian.
Median
Replaces each pixel with the median value of neighboring pixels. Good for removing noise while preserving edges.
Blur Intensity Examples
Low Intensity (1-3)
Subtle blur, good for slight softening
Medium Intensity (5-15)
Moderate blur, good for most use cases
High Intensity (20+)
Strong blur, creates a dreamy effect
How It Works
The blur effect works by averaging pixel values with their neighbors:
- Gaussian blur: Applies a weighted average where closer pixels have more influence than distant ones, based on a Gaussian distribution.
- Box blur: Applies a simple average of all pixels in a square area around each pixel.
- Median blur: Replaces each pixel with the median value of all pixels in a square area around it.
The intensity parameter controls the size of the area considered for each pixel. Higher values include more distant pixels, creating a stronger blur effect.
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid intensity value, invalid method, 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 blur effect is applied to all color channels (RGB) but does not affect the alpha channel (transparency) if present.
- Higher intensity values will result in longer processing times, especially for large images.
- The maximum file size allowed is 10MB.
- Gaussian blur provides the most natural-looking results but is more computationally intensive than box blur.
- Median blur is particularly effective for removing salt-and-pepper noise from images.
Use Cases
- Softening backgrounds to make foreground subjects stand out
- Creating a depth-of-field effect
- Reducing noise in images
- Creating a dreamy or ethereal look
- Protecting sensitive information by blurring it out
- Preparing images for overlaying text or graphics