Adjust Brightness
Adjust the brightness of an image to make it lighter or darker.
POST
/api/image/brightness
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to adjust. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
factor | Float | No | The brightness adjustment factor. Values > 1.0 increase brightness, values < 1.0 decrease brightness. Range: 0.1-3.0. Default: 1.0 . |
Response
Returns the brightness-adjusted image in the same format as the input file.
Example Request
curl -X POST "https://oyyi.xyz/api/image/brightness" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg" \
-F "factor=1.2" \
--output brightened.jpg
Example with Python
import requests
url = "https://oyyi.xyz/api/image/brightness"
files = {
'file': open('image.jpg', 'rb')
}
data = {
'factor': 1.2
}
response = requests.post(url, files=files, data=data)
# Save the brightened image
with open('brightened.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('factor', '1.2');
fetch('https://oyyi.xyz/api/image/brightness', {
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 = 'brightened.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Brightness Factor Examples
Low Factor (0.1-0.9)
Darkens the image
Normal Factor (1.0)
No change to brightness
High Factor (1.1-3.0)
Brightens the image
How It Works
Brightness adjustment works by multiplying each pixel's RGB values by the brightness factor:
- For each pixel, the R, G, and B values are multiplied by the brightness factor.
- Values are clamped to the valid range (0-255) to prevent overflow.
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid factor value, 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
- Very high brightness factors may result in loss of detail in bright areas due to clipping.
- Very low brightness factors may result in loss of detail in dark areas.
- For subtle brightening, use values between 1.1 and 1.5.
- For dramatic brightening, use values between 1.5 and 3.0.
- To darken an image, use values between 0.1 and 0.9.
- The maximum file size allowed is 10MB.
- This operation preserves the alpha channel (transparency) if present in the original image.
Use Cases
- Correcting underexposed images
- Enhancing details in dark areas
- Creating high-key or low-key effects
- Preparing images for print where brightness adjustments may be needed
- Darkening overexposed images
- Creating mood or atmosphere in images