Closed nicolasadamini closed 6 years ago
Hi Nicolas,
The error that you're getting is caused by not providing proper binary image data to the Tinify library.
In your case, probably something is going wrong posting the base64 encoded image data to the server. For example, a base64 encoded string can include spaces, which need to be properly url encoded/decoded when you're not using standard multipart/form-data and processing/posting it yourself with custom code. The code that you're using to convert the base64 encoded image data to binary data on the server is certainly correct.
Some examples to illustrate that compressing images with a buffer works:
When I convert an image that is base64 encoded to binary and then compress it, it works fine: https://gist.github.com/warflower/f320e53ac2362f7012a733538460ac4e This gist includes a simple 2x1 pixels image with two colors represented in base64 encoding.
I've also made a very basic example with file upload from a form and a nodejs server: https://gist.github.com/warflower/cfdb376e25d2d2a2eeea332156c99c09
I hope that helps you on your way!
Indeed thanks a lot ! I was using the wrong encoding type
Hello!
I've been trying to tinify a picture coming from the file API. While this works:
The following doesn't and I can't wrap my head around:
Server side
Client side
Full log
Using the aws-sdk the same 'buf' is working well so I don't know what to think...