How I can use the QuickChart to watermark image using the URL of the main image and the watermark image then return the URL of the generated image.
What should be the Accept, Content-Body and the Request Body
Hi @kingda,
Have a look at the parameters listed on the Watermarks documentation: Watermark API | QuickChart
These parameters can be supplied in the JSON request body, for example:
{
"mainImageUrl": "https://upload.wikimedia.org/wikipedia/commons/6/6e/Golde33443.jpg",
"markImageUrl": "https://1000logos.net/wp-content/uploads/2016/10/Batman-logo.png",
"markRatio": 0.25
}
Thank you for your repose. I follow the same exactly format for the request body but I am still getting the following error from WebServiceResponse
JSON error. Please make sure your POSTed JSON is valid: SyntaxError: Unexpected token â%â, â%7b%0d%0a+â⌠is not valid JSON
Also, When I change the advanced setting to turn off the Encode request body, It seems that I am getting return from the server but itâs Base64/Unknown format (Please check the picture below). Is that the correct value ? Shouldnât be the URL of the generated image?
the response from the server
Hi @kingda,
You should turn off âEncode request bodyâ. That will send the request correctly.
The response that youâre getting is the PNG image itself. This API endpoint returns an image, not a URL.
If all you need is a URL, then you can just construct the URL directly without using âInvoke Web Serviceâ, like so (see docs):
This URL goes straight to a PNG image.
Hope this helps!
Thank you so much, Thatâs really helpful!
Can you overlay the generated image(from the constructed URL) with a text/ another image ? and generated URL for the new image?
on other word, Can you watermark the original image with two images?
Hi @kingda,
Unfortunately there isnât a built-in way to do this. To apply a second watermark, youâd have to watermark the watermarked image.
For example:
{
"mainImageUrl": "<insert quickchart watermarked image URL here>",
"markImageUrl": "<second watermark URL>",
"markRatio": 0.25
}
Does that need to be done through API calls ?
Because the constructed URL (using the encoded URL of the watermarked image) timeout when I try to use URL for the watermarked image in the âmainImageUrlâ paramter.
below is the example of the constructed URL that timeout
https://quickchart.io/watermark?mainImageUrl=https%3A%2F%2Fquickchart.io%2Fwatermark%3FmainImageUrl%3Dhttps%253A%252F%252Fupload.wikimedia.org%252Fwikipedia%252Fcommons%252F6%252F6e%252FGolde33443.jpg%26markImageUrl%3Dhttps%253A%252F%252F1000logos.net%252Fwp-content%252Fuploads%252F2016%252F10%252FBatman-logo.png%26markRatio%3D0.25%0A
&markImageUrl=https%3A%2F%2F1000logos.net%2Fwp-content%2Fuploads%2F2016%2F10%2FBatman-logo.png
&markRatio=0.25
Can you please give example with real picture of the constructed URL using âQuickchart watermarked image URLâ ?
if you can please help me this timeout error. Thank you so much
Hi @kingda,
Apologies for the delay here. It looks like chaining watermark requests is a bit too much for the limitations of the free tier, which require that the operation completes in under 1 second.
One idea is that you could combine the two watermarks into a single watermark image, and use the API as originally outlined. Otherwise, weâd have to raise the image loading deadline, which is something that we canât do for free plans (as there is no way to identify your request specifically).
Ian