Image Processing

Introduction

Free to use Image Conversion Api. This conversion allow you to apply various filter, resize image, crop image and many other image editing tasks.

Conversion will be applied in same order as passed in request

Endpoint

Post
   https://api.oyyi.xyz/v1/image/convert

Content-Type: multipart/form-data

Parameters

  • file Required

    • Type: File or uuid
    • UUID can be id of previous conversion so that you don't have to re-upload file to server, and it will save network resource and timing.
      Max Size Allowed for file is 100MB by default. If you need more, you ask us to increase it for you. 429 Error will be return otherwise
  • resize

    This parameter is required to resize image by width , height parameter. Third parameter to maintain aspect ratio.
    • Type: string
    • Parameter Format: width,height,aspect_ratio
      1 for true to maintain aspect ratio and 0 for false
    • Example: - 100,100,1 or 100,100,0
  • blur

    Needed to blur image by given amount.
    • Type: number between range 0 to 100
    • Parameter Format: amount
    • Example: - 5
  • contrast

    Increase or decrease contrast of image by given amount.
    • Type: number
    • Parameter Format: -100 and 100
    • Example: 20 or -5
  • brightness

    Increase or decrease brightness of image by given amount.
    • Type: number
    • Parameter Format: -100 and 100
    • Example: 20 or -5
  • crop

    Crop the given image by given amount of width height.
    • Type: string
    • Parameter Format: width,height,x_position,y_position
      default value of x and y position is 0,0
    • Example: 100,100 or 120,120,30,50
  • flip

    flip the given image horizontally or vertically. .
    • Type: string
    • Parameter Format: h for horizontal and v for vertical flip
    • Example: h or v
  • gamma

    change the gamma value of image by given amount.
    • Type: amount
    • Parameter Format: amount can be any integer or decimal
    • Example: 3 or 5.7
  • greyscale

    convert the image in black and white.
    • Type: boolean
    • Parameter Format: 1 for true and 0 for false
    • Example: 1 or 0
  • invert

    invert the color of image.
    • Type: boolean
    • Parameter Format: 1 for true and 0 for false
    • Example: 1 or 0
  • opacity

    change the gamma value of image by given amount.
    • Type: number
    • Parameter Format: amount between 0 to 100
    • Example: 3
  • pixelate

    change the image pixel size by given value.
    • Type: number
    • Parameter Format: amount
    • Example: 9
  • rotate

    rotate the given image by given angel value.
    • Type: string
    • Parameter Format: angle,bg_colorangle can be between -360 to 360bg_color can be 'hex color'. Default is #000000
    • Example: -40 or -40,#f0f0f0
  • sharp

    sharp the given image color by given value.
    • Type: number
    • Parameter Format: amount between 0 and 100
    • Example: 10
  • format

    Format for converted image.
    • Type: string
    • Parameter Format: format in jpg jpeg png gif tiff webp
    • Default: format will be same as uploaded image
    • Example: png or webp
    Be careful while using format and custom converted filename at same time. Converted Filename extension should match the output format , otherwise it might cause unexpected behaviour
  • Extra Parameter

    Apart from these you can also all available common parameter available for media processing request. See Here

Example

Python
import requestsurl = $BASE_URL/image/converttoken = 'your_bearer_token_here'headers = {'Authorization': f'Bearer {token}'}params = {'resize': '300,200,1', 'rotate': '30'}files = {'file': open('example_file.jpg', 'rb')}response = requests.post(url,params=params, headers=headers, files=files)print(response.text)
Javascript
const axios = require('axios');const url = $BASE_URL/image/convert;const token = 'your_bearer_token_here';const formData = new FormData();formData.append('file', YOUR FILE);formData.append('resize', '300,240,1');formData.append('rotate', '40');const config = {  headers: {    'Authorization': `Bearer ${token}`,    'Content-Type': 'multipart/form-data'  }};axios.post(url, formData, config)  .then(response => console.log(response.data))  .catch(error => console.error(error));
Dart
import 'dart:io';import 'package:http/http.dart' as http;void main() async {   final url = Uri.parse('$BASE_URL/image/convert');  final headers = {'Content-Type': 'multipart/form-data'};  final request = http.MultipartRequest('POST', url);  request.headers.addAll(headers);  request.fields['resize'] = '300,240,1';  request.fields['rotate'] = '40';  request.files.add(await http.MultipartFile.fromPath('file', '/path/to/file'));  final response = await request.send();}
Laravel
use Illuminate\Http\Client\Response;use Illuminate\Support\Facades\Http;$url = '$BASE_URL/image/convert';$token = 'your_bearer_token_here';$response = Http::withHeaders([    'Authorization' => 'Bearer ' . $token,])->attach('file', $file_path)->post($url, [    "resize"=> "300,240,1",    "rotate" => "40"]);if ($response->successful()) {    $data = $response->json();} else {m    $message = $response->json()['message']m;}
Curl
curl -X POST \  -H 'Authorization: Bearer your_bearer_token_here' \  -d '{"resize": "300,240,1", "rotate": "40"}' \  -F 'file=@/path/to/your/file' \  $BASE_URL/optimize

Response

Default
{  "data": {    "id": "4c27a32a-8d3e-4ad4-a19c-91063cb0483f",    "converted_file": "your_random_converted_file.jpg",    "created_at": "2023-02-22T06:25:35.659015Z",     "status": "done"  }}
Upload Original
{  "data": {    "id": "dd4409a1-68bf-4e0f-821a-498e19c6fdcc",    "converted_file": "your_random_converted_file.jpg",    "original_file": "my_original.jpg",    "created_at": "2023-02-22T06:26:53.031758Z",    "status": "queued"  }}
You can visit here to know to you can fetch file by id.