Hello, My team and I are currently working on issue #4125 as part of our CodeDay internship. Our goal is to create a compressed image function in Java.
The compressed image returned in base64 format is generally good, but we've encountered some cases where escape characters appear (as shown in the attached screenshot 1 & 2), which renders the result invalid.
I attempted to remove these characters using the "replaceAll("", "")" method, but encountered an error (also shown below screenshot 3).
Could you please advise on the correct way to resolve this issue? Thank you.
public RuntimeResponse main(RuntimeRequest req, RuntimeResponse res) throws Exception {
...
// compressed image in Base64 string
String compressedImage = "";
Map<String, Object> responseData = new HashMap<>();
if (Provider.TINY_PNG.getName().equals(provider)) {
// Decode image from Base64 string
byte[] imageByte = convertToByte(image);
// Compress image
byte[] compressedImageByte = tinifyCompress(imageByte, apiKey);
// Encode image to Base64 string
compressedImage = convertToBase64(compressedImageByte).replaceAll("\\", "");
}
responseData.put("success", true);
responseData.put("image", compressedImage);
return res.json(responseData);
}
Maybe that backslash is just because it's JSON encoded?
Yes, I think it’s JSON encoded. Should we just leave it?
Go ahead and submit the PR and we'll see
Thank you so much, I will do that.
Adding the link here for reference : https://github.com/appwrite/appwrite/issues/4125
Did you submit the PR yet?
I intend to submit the PR once we finish implementing the compressed image Kraken IO method. Would you like me to submit the current code?
Up to you. I thought it was already submitted but I didn't see the PR in the issue
Once we complete the final method, expected to be done within this week, I will submit it and inform you. Thank you!
Hi, I want to inform you that we submitted the PR. Here is the link: https://github.com/open-runtimes/examples/pull/174 Thank you.
Recommended threads
- Hi, I'm getting this error while deployi...
✗ Error • search (6937cb70002c2e9c1a97) • Fai ✗ Error: Deployment of search has failed. Check at https://cloud.appwrite.io/console/project-693...
- Timed out waiting for runtime. Error Cod...
After setting up my ML project that uses deepface and tensorflow in appwrite functions I get the `Timed out waiting for runtime. Error Code: 400. ` error. I am...
- Bug: Cloud Function On Schedule Didn't R...
Heya I have a cloud function with this cron `0 17 * * *` to run at 9AM PT every day. I have not touched this since I set it up, and it has been working fine s...