Oyyi

Invert Colors

Invert all colors in an image, creating a negative effect.

POST /api/image/invert

Request Parameters

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

Response

Returns the image with all colors inverted, in the same format as the input file.

Example Request

    curl -X POST "https://oyyi.xyz/api/image/invert"   -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@image.jpg" \
  --output inverted.jpg
  

Example with Python

    import requests

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

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

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

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

Example with JavaScript

    // Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);

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

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

How It Works

The color inversion process works by subtracting each RGB color value from the maximum possible value (255). For each pixel:

R_new = 255 - R_original
G_new = 255 - G_original
B_new = 255 - B_original

This creates a negative effect where light areas become dark and dark areas become light, while colors are transformed to their complementary colors.

Error Responses

Status CodeDescription
400Bad request. Missing required parameters 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 inversion applies to all color channels (RGB) but does not affect the alpha channel (transparency) if present.
  • Inverting an already inverted image will restore it to its original colors.
  • The maximum file size allowed is 10MB.
  • This operation is particularly useful for creating artistic effects or improving the visibility of certain features.

Use Cases

  • Creating artistic negative effects
  • Improving visibility of low-contrast details
  • Preparing images for specific scientific or medical analysis
  • Creating high-contrast versions of images for accessibility purposes
  • Generating complementary color schemes from existing images