Convert image format
Creates a task to convert an image file to a different format.
API Key for authentication
In: header
The id of the file or task to operate on.
The name of the image to be saved
The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use webhooks
instead.
uri
The format to convert the image to.
The id of the file or task to operate on.
The name of the image to be saved
The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use webhooks
instead.
uri
The format to convert the image to.
Image quality (1-100) for lossy formats like jpeg.
75
1 <= value <= 100
The id of the file or task to operate on.
The name of the image to be saved
The URL to call when the task is completed or failed. If you want to receive events, you probably prefer to use webhooks
instead.
uri
The format to convert the image to.
Image quality (1-100) for lossy formats like webp.
75
1 <= value <= 100
Response Body
curl -X POST "https://api.scan-documents.com/v1/image-operations/convert" \
-H "Content-Type: application/json" \
-d '{
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
}'
const body = JSON.stringify({
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
})
fetch("https://api.scan-documents.com/v1/image-operations/convert", {
body
})
package main
import (
"fmt"
"net/http"
"io/ioutil"
"strings"
)
func main() {
url := "https://api.scan-documents.com/v1/image-operations/convert"
body := strings.NewReader(`{
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://api.scan-documents.com/v1/image-operations/convert"
body = {
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
}
response = requests.request("POST", url, json = body, headers = {
"Content-Type": "application/json"
})
print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;
var body = BodyPublishers.ofString("""{
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
}""");
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("https://api.scan-documents.com/v1/image-operations/convert"))
.header("Content-Type", "application/json")
.POST(body)
.build();
try {
HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
System.out.println("Status code: " + response.statusCode());
System.out.println("Response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;
var body = new StringContent("""
{
"input": "file_avyrvozb9302uwhq",
"target_format": "image/png"
}
""", Encoding.UTF8, "application/json");
var client = new HttpClient();
var response = await client.PostAsync("https://api.scan-documents.com/v1/image-operations/convert", body);
var responseBody = await response.Content.ReadAsStringAsync();
{
"id": "task_euyrvozb9302uwhq",
"operation": "convert",
"parameters": {
"input": "file_avyrvozb9302uwhq",
"name": "Example Image",
"callback_url": "https://example.com/callback",
"target_format": "image/png"
},
"status": "completed",
"result": {
"generated_files": [
{
"id": "file_euyrvozb9302uwhq",
"name": "Example Image",
"type": "image/png",
"properties": {
"size": 1024,
"width": 800,
"height": 600
},
"task_id": "task_euyrvozb9302uwhq",
"created_at": "2021-05-01T12:00:00Z"
}
]
},
"callback_url": "https://example.com/callback",
"created_at": "2021-05-01T12:00:00Z",
"updated_at": "2021-05-01T12:00:00Z"
}
{
"type": "https://scan-documents.com/docs/errors/not-found",
"title": "Not Found",
"status": 404,
"message": "{resource} with id {id} not found."
}
{
"type": "https://scan-documents.com/docs/errors/validation-error",
"title": "Validation Error",
"status": 422,
"errors": {
"{field}": [
"{error}."
]
}
}
{
"type": "https://scan-documents.com/docs/errors/rate-limit-error",
"title": "Rate Limit Exceeded",
"status": 429,
"message": "Rate limit exceeded. Please try again later or contact support."
}
{
"type": "https://scan-documents.com/docs/errors/internal-error",
"title": "An unexpected error occurred. Contact support if the problem persists.",
"status": 500,
"message": "An unexpected error occurred. Contact support if the problem persists."
}