examples icon indicating copy to clipboard operation
examples copied to clipboard

Add Compress Image for Ruby

Open vzsky opened this issue 3 years ago • 3 comments
trafficstars

Closes: https://github.com/appwrite/appwrite/issues/4123

I use this python script below to test the api call,

import requests
import json

url = "http://localhost:3000"
provider = "krakenio"
image = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAs...wIKAMAOCkkTBNfnUoAAAAASUVORK5CYII="

headers = {
  "X-Internal-Challenge": "secret-key",
  "Content-Type": "application/json"
}
payload = {"provider": provider, "image": image}
variables = {
  "TINYPNG_API": "ng...9",
  "KRAKENIO_KEY": "24...3",
  "KRAKENIO_SECRET": "dc...1"
}
data = {"payload": json.dumps(payload), "env": variables}

r = requests.post(url = url, headers = headers, json=data)
print(r)
print(r.json())

which then produce this result,

{
'success': True, 
'image': 'iVBORw0KGgoAAAANSUhEUgAAAAQAAAAGCAIAAABrW6giAAAAMUlEQVQYGQXB\nAQ2AAAzAsO25f1MEG0j5aH2frw4YZ6mqwNtAVYGpQOjuBohUdQEiUn+73Bpx\nfmGEqAAAAABJRU5ErkJggg==\n'
}

This works for both tinypng and krakenio for supposedly any .png files

vzsky avatar Oct 08 '22 14:10 vzsky

Thank you so much for the PR 🤩. We're adding the hacktoberfest-accepted label to ensure this PR counts towards your Hacktoberfest contributions count. With that said, please stay active on this PR to address any comments once you receive a review. Happy Hacktoberfest! 🎃

Meldiron avatar Oct 31 '22 16:10 Meldiron

Changed according to the comments, and also add a simple tester in python. Not sure if it will be helpful or not.

vzsky avatar Nov 01 '22 17:11 vzsky

All requests fixed and committed.

vzsky avatar Nov 23 '22 07:11 vzsky

Thanks for the amazing PR 😇 I have added small changes documentation. Merging the PR now 🥳

Meldiron avatar Jan 22 '23 09:01 Meldiron