Open brinkbrink opened 1 year ago
Closes https://github.com/appwrite/appwrite/issues/4125
Authors: Tin Pham, E. Brink, Ali Sharif.
This pull request creates a Java function that performs lossless compression on an image by integrating Tinypng and KrakenIO API.
image and provider are recieved from the payload, where image is a base64 encoded string and provider is either tinypng or krakenio
image
provider
tinypng
krakenio
Example input:
{ "provider": "tinypng", "image": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAf0lEQVR4nO2Wuw2AMAxEbw1gpMwDDMBcGQpooDKydGVAoXCK6J7k6qyc83MCCFGP/Yz+CkDF4KHmjgowbQF0CKFrCDUiwztqxabHCL0/xwcNhoI2UdsjC8g0mQvaSs1zwkg0uQAsAEaGm9/UPCeU7eMj6loTEpf6ZOQWMxd98gAhZnS6XEZcNQAAAABJRU5ErkJggg==", }
krakenio is also a supported provider
Example output:
{ "success": true, "image": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAG1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACUUeIgAAAACHRSTlMA8712Sxr5g97cFtUAAAA9SURBVCjPY6Aa6AADfAIcDSA8KoBTgLGVgSFCAEmAqZmBwUIBSYClzTQ4wwE52Cs6OtpR4oFFUciBerEKAP58HnyLtZsYAAAAAElFTkSuQmCC" }
README.md contains instructions on how to run the main function.
{"provider":"krakenio","image":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAEoSURBVDiNpdM9K4VhGAfw33kOJSTOUVIGFhNFFjux+AiOMlkVFouMFmWVfAeDQcoHUAbFwBmwGZwn8hblZXhu9Xg6Ogf/urq77v/Vdd//64V/Ipfxm1FEJ6LgwxPecYNK8L9hBmV81GlllKABU9jCCg7wGOw2nN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Qj4/CLNJ4lVV/CGYYwiZdUTAFxFLQUMwl2cSTpzCqGg4w0iogbcImBDPmA8RrSBnGRxz3WJBpf0SEZlly4y0va2o0e9GEW81j8ylbCufpH+RzT/LxMxfByepneJPWqukx/xienmFIUmYAfWAAAAABJRU5ErkJggg=="}
{ "image": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAZlBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwbJTWAAAAIXRSTlMAXDEfBm5JEgv27tvRN+Sxmj0s4Lx7eXRgS\/DVo6BXVDhCV9reAAAAe0lEQVQY021P2RKEIAwrtxTwXHXdU\/7\/JwU8ZzAvmWaaNIU7FIzSpqGUFWkkxh8wBGDSg2uZ4lyx1g1eQlVf3XUFVsSURzfyKAgLJQn8R4HvOQaWoGXgZwfq+wo7Up\/CB5OwWn44onXJsocasYXmZyffn8V6L7Pq2XMZFmhUCEnCfrHCAAAAAElFTkSuQmCC", "success": true }
Checklist:
Closes https://github.com/appwrite/appwrite/issues/4125
Authors: Tin Pham, E. Brink, Ali Sharif.
Summary
This pull request creates a Java function that performs lossless compression on an image by integrating Tinypng and KrakenIO API.
image
andprovider
are recieved from the payload, whereimage
is a base64 encoded string andprovider
is eithertinypng
orkrakenio
Example input:
Example output:
Details
README.md contains instructions on how to run the main function.
Testing
Kraken Input:
KrakenIO Output:
TinyPNG Input:
TinyPNG Output:
Size testing results: