Upgrade from Let's Enhance to Picsart's Advanced Upscale APIs
Learn how to switch from LetsEnhance.io to Picsart's Upscale API, leveraging enhanced features for more precise and customizable image upscaling. Ideal for developers looking to improve workflow and output quality in their projects.
Transitioning from Let's Enhance to Picsart's Upscale API offers you an array of advanced features for enhancing your image processing workflows. This article will guide you through the migration process, detailing the similarities and additional capabilities provided by Picsart, to ensure a smooth transition for your projects.
Understanding the Basics
Both Let's Enhance and Picsart provide robust solutions for upscaling images, but Picsart offers simplified functionality to better tailor the results to your specific needs. While the basic premise of sending an HTTP POST request to upscale an image remains the same, switching to Picsart opens up new possibilities with additional parameters and customization options.
Code Example for Let's Enhance *
Here's how a typical API call looks like with Let's Enhance:
curl -X POST --location "http://api.claid.ai/v1-beta1/image/edit" --http1.1 \
-H "Host: api.claid.ai" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"input\": \"https://claid.ai/doc-samples/bag.jpeg\",
\"operations\": {
\"resizing\": {
\"width\": \"200%\",
\"height\": \"200%\"
},
\"restorations\": {
\"upscale\": \"photo\"
}
},
\"output\": {
\"format\": {
\"type\": \"jpeg\",
\"quality\": 90
}
}
}"
This command sends an image file to Let's Enhance, specifying the image should be upscaled by 2 times and setting the output format to be JPG and compression to 90%.
Transitioning to Picsart's Upscale API
Migrating to Picsart not only involves changing the API endpoint but also taking advantage of making a much simpler call that enhance your control over the upscaling process. Here's how you can adapt the above Let's Enhance API call to use Picsart’s API:
curl -H 'X-Picsart-API-Key: YOUR_PICSART_API_KEY' \
-H 'accept: application/json' \
-H 'content-type: multipart/form-data' \
-F 'upscale_factor=2' \
-F 'format=JPG' \
-F 'image_url=https://claid.ai/doc-samples/bag.jpeg'
-f
-X POST https://api.picsart.io/tools/1.0/upscale
In this updated API call for Picsart:
upscale_factor=2
aligns with thewidth
,height
parameters in Let's Enhance, focusing on multiplying the resolution of the original image.- Additional parameters like
format
can be added, which will give you more control over the final output. - The
restorations:upscale
property doesn't have a direct analogue in Picsart. Picsart processes all images in a generic way. Instead, we recommend reading this article about picking the best Upscale service for your business needs. There are three services with slight differences in the technology and the output image quality: Upscale, Ultra Upscale and Ultra Enhance. Here are a couple of good reads about how to choose the best upscale service for your business:
Input Image and the differences between the two services
Unlike Let's Enhance that accepts only URLs to the input image:
{
"input": "https://letsenhance.io/docs/assets/samples/burger.jpg"
}
{
"input": "storage://storage-name/path/image-name.jpg"
}
Picsart allows to define the input image also via a reference image identifier, as well as via a direct upload using the multipart/form-data
request's content type.
This table highlights the functional similarities and features of both APIs, helping users understand how to map parameters when migrating from one service to another.
Feature | Remove.bg parameter | Description | Picsart parameter | Description |
---|---|---|---|---|
Source Image File | (not supported) | Source image file (binary). (If this parameter is present, the other image source parameters must be empty.) | image | Source image file (binary). |
Source Image reference | (not supported) | image_id | Source image identifier. | |
Source Image URL | input | Source image URL. Accepts either a public URL or a storage URL. Input Image format options are BMP, GIF, JPEG, PNG, TIFF, WEBP, AVIF, and HEIC. | image_url | Source image URL. Any public URL. Input image formats are JPG, PNG, TIFF and WEBP. |
Image Format | output:format:type | Result image format options: JPEG, PNG, WEBP, and AVIF. | format | Select from JPG, PNG, WEBP; defaults to PNG. ZIP is not supported. |
Output Resolution | width, height | Specifies the size of the output image. The width and height parameter supports dynamic sizing and is based on pixels or percent values. Example values are 1000, and "200%". | upscale_factor | The upscale factor. The basic version supports up to 800% upscaling. Ultra Upscale and Ultra Enhance upscale up to 1600%. |
Choosing the correct upscale factor
As illustrated above, Picsart's Upscale API utilizes the upscale_factor
parameter, which accepts integer
values such as 2, 4, or 12. This parameter scales each dimension of the image by the specified factor; for example, upscale_factor=4
effectively quadruples the dimensions of the image, equivalent to setting width: "400%"
.
If your existing code specifies width and height in percentages, converting to Picsart's system is straightforward: simply replace a 400% scaling with upscale_factor=4
. If your current dimensions are in exact pixels, you'll need to perform a brief calculation to determine the most suitable upscale factor. For instance, if your original image is 512 x 512 pixels and you're aiming for a size of 800 x 800 pixels, an upscale_factor=2
would be appropriate, as it would scale your image to 1024 x 1024 pixels, closely matching your target dimensions.
The following code demonstrates it in action:
function calculateUpscaleFactor(originalWidth, originalHeight, targetWidth, targetHeight) {
const widthFactor = Math.ceil(targetWidth / originalWidth);
const heightFactor = Math.ceil(targetHeight / originalHeight);
return Math.max(widthFactor, heightFactor);
}
// Example usage
const originalWidth = 512;
const originalHeight = 512;
const targetWidth = 800;
const targetHeight = 800;
const upscaleFactor = calculateUpscaleFactor(originalWidth, originalHeight, targetWidth, targetHeight);
console.log('Recommended Upscale Factor:', upscaleFactor);
Handling the Response
Example of Let's Enhance Response
{
"data": {
"input": {
"ext": "jpeg",
"mps": 4.1472,
"mime": "image/jpeg",
"format": "JPEG",
"width": 2880,
"height": 1440
},
"output": {
"ext": "jpeg",
"mps": 0.64,
"mime": "image/jpeg",
"format": "JPEG",
"width": 800,
"height": 800,
"tmp_url": "....."
}
}
}
Picsart's Response
Conversely, Picsart standardizes its responses by consistently returning them in JSON format. This uniform approach ensures that responses are predictable and structured, facilitating easier data handling and integration into applications. When using Picsart's API, developers can expect a JSON response containing URLs and status information, which provides a reliable and consistent method for accessing and using the processed image data.
{
"status": "success",
"data": {
"id": "e7bd38.....b1593.png",
"url": "https://cdn.picsart.io/e7bd38...b1593.png"
}
}
Migrate Response Handling
1. Adjust Response Parsing Logic
- If your application currently handles Let's Enhance’s response by utilizing the
output:tmp_url
, you will need to adjust it to utilize thedata:url
provided by Picsart for displaying or processing the image.
2. Update Error Handling
- Adapt your error handling mechanisms to account for the "status" field in the Picsart response to manage different states of the response effectively.
3. Testing and Validation
- Thoroughly test the new implementation with a variety of images to ensure that the Picsart API meets all your application's requirements and that the image handling logic works correctly across all expected scenarios.
Benefits of Migrating to Picsart
Switching to Picsart’s API can enhance your application’s capabilities with:
- Advanced image processing features that allow more customization.
- Greater control over output settings which can lead to better integration into your existing systems or workflows.
That's All
Migrating from Let's Enhance to Picsart's Upscale API is not only straightforward but also beneficial, providing advanced features and greater flexibility. By utilizing the detailed parameters and options that Picsart offers, you can elevate the quality of your image upscaling tasks and tailor the outputs more closely to your project's requirements.
*Please note that the code examples and API documentation for Let's Enhance provided here were last verified as of May 1st, 2024. The original documentation and services may have undergone changes since the publication of this article.
Updated 3 months ago