A blurry photo and a small photo need different treatments. The Image Deblur API reduces motion blur without changing dimensions. The Image Upscale API enlarges images or enhances them at their original size. This guide shows how to select the operation, send a request, and save the result.
For ecommerce and campaign production, photo enhancement often sits alongside background removal and text and watermark removal. Use these as separate, optional steps rather than running every image through every endpoint.
Deblur or Upscale: Which Should You Use?
Start with the problem you can see in the source. Enlarging a blurred image is not the same as reducing its blur, and sharpening does not add the missing pixels of a low-resolution original.
| Image problem | Request | Output dimensions |
|---|---|---|
| Motion blur or camera shake | POST /deblur | Original width and height |
| A photo too small for a gallery or campaign layout | POST /upscale, scale=2 | Twice the width and height |
| Enhancement without enlargement | POST /upscale, scale=1 | Original width and height |
For example, a 1000 × 750 image becomes 2000 × 1500 at scale 2: twice each dimension and four times as many pixels. Neither operation guarantees recovery of missing text, faces, or fine product details. Keep the source and review the result before publishing.
The DEBLUR reference and UPSCALE reference document the full request parameters, response fields, and supported formats.
Add Background Removal and Text Cleanup
For store listings, a clear subject and an uncluttered image can matter as much as resolution. A product photo may need a transparent cutout; an approved campaign asset may need an old caption removed. Choose the processing step that addresses that specific need.
Product cutouts
The Background Removal API isolates the subject automatically, without a manually prepared mask. Use it for transparent product images, marketplace listings, and campaign layouts.
Follow the background removal tutorial →Text and overlay cleanup
The Text and Watermark Removal API removes captions, timestamps, annotations, and permitted watermarks, then reconstructs the covered areas. No mask or separate OCR request is required.
Follow the text removal tutorial →For a catalog import, first identify which images need cleanup, blur reduction, or enlargement. Run only those operations, keep intermediate files, and review the final image at the size it will be displayed. Check each endpoint's format and size requirements before passing output to the next step.
Watch the size between steps. A 2000 × 2000 input is within the 4-million-pixel limit of DEBLUR and UPSCALE. After 2x upscaling, it is 4000 × 4000, or 16 million pixels, so it cannot be sent directly to DEBLUR. Enlargement often belongs near the end of a workflow, but test the processing order on your own images.
Use authorized images. Remove text or watermarks only from images you own or have permission to modify. Do not erase third-party ownership marks without permission, or remove product information that customers need.
1. Prepare an Image and API Key
Open the PixLab Console to create your API key and review the available trial, usage allowance, and account limits. Both endpoints accept JPEG, PNG, and WebP inputs up to 4,000,000 pixels and 10 MiB. Larger inputs are rejected, not silently resized.
- Check width × height and file size before submitting a request. The examples below check file size; pixel dimensions are still validated by the API.
- Use a local image such as
photo.jpgthat you own or are authorized to process. - Keep the key on your backend. Do not commit a real API key to source control or include it in logs.
2. Unblur or Upscale an Image
Choose Python or JavaScript. Both examples upload an image, check the response, and save the processed file or return its S3 link.
Get your API key from the PixLab Console, then copy the Python example below to try it with your own photos. Use Python 3 with the requests package installed, replace YOUR_API_KEY, and set the path to your image. The example uploads the file, checks HTTP and API status, and saves the output or returns its S3 link.
import base64
from pathlib import Path
import requests
API_KEY = "YOUR_API_KEY"
MIME_TYPES = {
".jpg": "image/jpeg", ".jpeg": "image/jpeg",
".png": "image/png", ".webp": "image/webp",
}
def process_image(source, operation, scale=2):
if operation not in {"deblur", "upscale"}:
raise ValueError("Choose deblur or upscale")
if scale not in {1, 2}:
raise ValueError("Scale must be 1 or 2")
source = Path(source)
mime = MIME_TYPES.get(source.suffix.lower())
if not mime:
raise ValueError("Use a JPEG, PNG, or WebP image")
if source.stat().st_size > 10 * 1024 * 1024:
raise ValueError("Input exceeds 10 MiB")
params = {"scale": scale} if operation == "upscale" else {}
with source.open("rb") as image:
response = requests.post(
f"https://api.pixlab.io/{operation}",
headers={"WWW-Authenticate": API_KEY},
files={"file": (source.name, image, mime)},
data=params,
timeout=(10, 120),
)
response.raise_for_status()
result = response.json()
if result.get("status") != 200:
raise RuntimeError(result.get("error", "Image processing failed"))
if result.get("link"):
return result["link"]
extension = result.get("extension")
if extension not in {"png", "jpeg", "jpg", "webp"}:
raise ValueError("Unexpected output format")
output = source.with_name(f"{source.stem}-{operation}.{extension}")
output.write_bytes(base64.b64decode(result["imgData"], validate=True))
return str(output)
if __name__ == "__main__":
print(process_image("photo.jpg", "deblur"))
Upscale instead of deblurring
To double the width and height, replace the final function call above with:
print(process_image("photo.jpg", "upscale", scale=2))
Use scale=1 for enhancement at the original size. Choose the operation your image needs; you do not need to run both. Outputs are saved beside the source with a -deblur or -upscale suffix. The original is unchanged; rerunning an operation replaces its generated output file.
Use this example in a Node.js 20+ backend as an .mjs module. Get your API key from the PixLab Console, replace YOUR_API_KEY, and set your image path. Keep the key on the server, not in browser code. The example uses built-in fetch and FormData, so no additional HTTP package is required.
// Node.js 20+, running on your backend.
import { readFile, writeFile } from "node:fs/promises";
import { extname, parse, join } from "node:path";
const API_KEY = "YOUR_API_KEY";
const MIME_TYPES = {
".jpg": "image/jpeg", ".jpeg": "image/jpeg",
".png": "image/png", ".webp": "image/webp",
};
async function processImage(source, operation, scale = 2) {
if (!["deblur", "upscale"].includes(operation)) {
throw new Error("Choose deblur or upscale");
}
if (![1, 2].includes(scale)) throw new Error("Scale must be 1 or 2");
const mime = MIME_TYPES[extname(source).toLowerCase()];
if (!mime) throw new Error("Use a JPEG, PNG, or WebP image");
const image = await readFile(source);
if (image.length > 10 * 1024 * 1024) throw new Error("Input exceeds 10 MiB");
const form = new FormData();
form.append("file", new Blob([image], { type: mime }), parse(source).base);
if (operation === "upscale") form.append("scale", String(scale));
const response = await fetch("https://api.pixlab.io/" + operation, {
method: "POST",
headers: { "WWW-Authenticate": API_KEY },
body: form,
signal: AbortSignal.timeout(120000),
});
if (!response.ok) throw new Error("HTTP " + response.status);
const result = await response.json();
if (result.status !== 200) throw new Error(result.error || "Image processing failed");
if (result.link) return result.link;
if (!["png", "jpeg", "jpg", "webp"].includes(result.extension)) {
throw new Error("Unexpected output format");
}
if (typeof result.imgData !== "string" || !result.imgData) {
throw new Error("Missing image data");
}
const { dir, name } = parse(source);
const output = join(dir, name + "-" + operation + "." + result.extension);
await writeFile(output, Buffer.from(result.imgData, "base64"));
return output;
}
processImage("photo.jpg", "deblur")
.then((output) => console.log(output))
.catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
To double the width and height, replace the final processImage call with processImage("photo.jpg", "upscale", 2), keeping the same success and error handlers. Use 1 instead of 2 for enhancement at the original dimensions.
As in the Python example, the result is a saved image path or a link to output in your connected S3 bucket. The source stays unchanged; rerunning an operation replaces its generated output file. Let FormData set the multipart Content-Type and boundary automatically.
3. Handle the Processed Image
- Base64 JSON: check
status, then decodeimgData. Use the returnedextensionandmimeTyperather than assuming that output is JPEG. - Your AWS S3 bucket: when configured in the Console,
linkcan replaceimgData. Store the URL in your asset record and manage access through your storage configuration. - Raw bytes: send
blob=truewhen your integration needs an image response instead of JSON. Check HTTP status and Content-Type before saving: an error can still arrive as JSON. The examples above use the default JSON mode.
Keep the original and generated versions separate. After quality review, use the processed file in your website, store, or campaign. If your frontend needs additional sizes, formats, or delivery through a CDN, handle those as explicit publishing steps.
Plan for High-Volume Image Processing
DEBLUR and UPSCALE are designed for high-volume processing, with one image per request. Bulk processing belongs in your application: use a queue rather than sending an entire catalog at once. The same approach supports background removal and authorized text cleanup.
- Create one job per image and operation. Record the source asset ID, requested endpoint, scale setting, output location, and completion state. Use unique output names for production jobs; the example function is intended for individual files.
- Limit both concurrency and request rate. Start with a small worker pool and tune it to the limits shown in your account. More workers do not guarantee more throughput.
- Handle failures deliberately. Fix invalid inputs or authentication errors rather than retrying them. For temporary failures and rate limits, use bounded retries with backoff and jitter; honor Retry-After when supplied.
- Account for ambiguous timeouts. A client timeout does not prove that processing never happened. Avoid endless retries, which may repeat work and consume additional usage.
- Keep a review path. Compare labels, faces, product textures, and brand details with the source before automatically publishing important assets.
A photo sent to two endpoints requires two requests. Estimate the total operations, not just the image count, and check how each is accounted for in your plan. See monthly API plans and your Console usage and limits. For sustained workloads, share your daily image volume and dimensions with PixLab support before scaling up.
Review Results and Resolve Common Errors
The image is rejected
Check the format, file size, pixel count, API key, and account limits. Read the JSON error message. For a URL input, confirm that the address points directly to an image and is reachable without authentication.
The output looks clearer but details changed
Deblurring and super-resolution estimate detail. Severe blur, compressed images, fine patterns, faces, and small lettering need careful review. A sharper-looking result is not proof that reconstructed information is correct.
There is no Base64 image in the response
Check for a link to output in your connected S3 bucket. If you requested blob=true, handle image bytes instead of calling response.json().
The next operation rejects an enlarged image
Check the new dimensions and byte size. A successful UPSCALE output is not automatically a valid input for another endpoint. Review the processing order instead of blindly forwarding every result.
Deblurring and Upscaling Questions
Can I unblur any photo with an API?
No. DEBLUR reduces motion blur and camera shake, but severe blur, missing detail, and heavy compression can prevent faithful restoration. Review faces, lettering, and product details against the original.
Does deblurring increase image resolution?
No. DEBLUR preserves the original width and height. Use UPSCALE with scale=2 to double both dimensions, or scale=1 for enhancement at the original size.
What are the input limits for DEBLUR and UPSCALE?
Both endpoints accept JPEG, PNG, and WebP images up to 4,000,000 pixels and 10 MiB. These are input limits. An enlarged output may exceed the input limit of a later processing step.
Can I deblur and upscale images in bulk?
Yes. Each endpoint processes one image per request. Use a queue with bounded concurrency, respect your account's request and usage limits, and track each image and processing step separately.
Can I also remove backgrounds, text, and watermarks?
Yes. BG-REMOVE isolates subjects, while TXT-REMOVE removes text overlays and permitted watermarks. Use only images you own or are authorized to edit, check each endpoint's input limits, and review the result before publication.
Test Your Own Product Photos
Create your API key in the PixLab Console and use either inline example to test a few representative images. Compare the originals and results, confirm your account limits, and build only the processing steps your application needs.
Continue with the Background Removal API for product cutouts or the Text and Watermark Removal API for authorized image cleanup.