Compress
Synchronous image compression. The response body is the transformed image.
curl
curl -X POST https://api.opusimg.com/v1/compress \
-H "Authorization: Bearer $OPUSIMG_API_KEY" \
-F "image=@photo.jpg" \
-F "quality=80" \
-F "format=webp" \
--output photo.webpJavaScript
const form = new FormData();
form.append("image", file);
form.append("quality", "80");
form.append("format", "webp");
const response = await fetch("https://api.opusimg.com/v1/compress", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.OPUSIMG_API_KEY}` },
body: form,
});
const image = await response.blob();