Upscale An Image
This guide will walk you through how to upscale an image using Core3D's API via HTTP requests.
When might you need to upscale an image? As an example, you might run an e-commerce shop that allows users to design their own tee shirts. Users can modify their designs using lower resolution images and complete check out, only after create an upscale (2k, 4k, etc.) to get the resolution you need for production.
Note: You'll need an API token to perform any of these actions. See the Authentication section of the API Reference. We'll use
$TOKEN
as a placeholder for your API token in the examples below.
Contents
- Step 1 — Pick An Image Upload
- Step 2 — Create an Upload Variant
- Step 3 — Check The Status
- Step 4 — View The Results
Step 1 — Pick An Image Upload
We need to pick the Upload we want to upscale. We'll use one of the generated images from the Generate An Image guide (our URI is core3d:upload:018d7045-c918-7add-921f-9fd36a42e5d8
).
Step 2 — Create an Upload Variant
We'll make a request to the API to create a new Upload Variant with a type of "2k" -- this will upscale our image to a resolution of 2048 across the smallest dimension.
Request
$ curl -X POST https://api.core3d.io/v1/upload-variants \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"source": "core3d:upload:018d7045-c918-7add-921f-9fd36a42e5d8",
"type": "2k"
}'
Response
{
// ... additional properties omitted
"id": "018f7e64-16bf-74e7-9b28-b891a7077f7c",
"uri": "core3d:upload-variant:018f7e64-16bf-74e7-9b28-b891a7077f7c",
"result": null,
"status": "pending"
}
Step 3 — Check The Status
We can poll the API using the id
or uri
from the last request until the upload variant is done processing. The status
will change from "pending" to "running", and we'll know it's done when the status
property reads "ok". If the status
reads "error", something went wrong.
Request
# For convenience, you can use a URI as the ID parameter in API requests
$ curl https://api.core3d.io/v1/upload-variants/core3d:upload-variant:018f7e64-16bf-74e7-9b28-b891a7077f7c \
-H "Authorization: Bearer $TOKEN"
Response
{
// ... additional properties omitted
"id": "018f7e64-16bf-74e7-9b28-b891a7077f7c",
"uri": "core3d:upload-variant:018f7e64-16bf-74e7-9b28-b891a7077f7c",
"result": {
"id": "018f7e66-8c6c-7a49-bd50-c4b7fc11dd86",
"uri": "core3d:upload:018f7e66-8c6c-7a49-bd50-c4b7fc11dd86"
},
"status": "ok"
}
The Upload Variant is done. Let's view the results.
Step 4 — View The Results
The result
property contains the identity information of the resulting Upload resource. We can use the id
or uri
property to request the full Upload resource and a URL to the new image.
Request
$ curl https://api.core3d.io/v1/uploads/core3d:upload:018f7e66-8c6c-7a49-bd50-c4b7fc11dd86 \
-H "Authorization: Bearer $TOKEN"
Response
{
// ... additional properties omitted
"id": "018f7e66-8c6c-7a49-bd50-c4b7fc11dd86",
"uri": "core3d:upload:018f7e66-8c6c-7a49-bd50-c4b7fc11dd86",
"url": "https://static.production.core3d.io/..."
}