I am trying to crop images in the browser and upload them to a server as raw image binary data (the format should be "image/jpeg" or "image/png"). I tried many client-side crop & upload methods, they all use the html 5 function canvas.toDataURL() to get the final cropped data in "data:image/png;base64" format, upload it to the web server and then convert it into raw image binary data at the server side.
The thing is that I have to upload the cropped data into a static file server like AWS S3 which can't execute converting code, except for accepting file uploading. Therefore, what I need is to upload the cropped images as a normal image format like "image/png". If this can be done, I can use the browser to crop & upload images directly to the file server (S3) and I don't need a middle server to convert the image data and transfer it to the file server (S3).
Resize your images to fill specified dimensions by setting the width and height (w and h in URLs), while setting the crop parameter to fill (c_fill in URLs). This will resize and crop the image so an image with the exact specified dimensions is generated.
You can try Crop Upload, a HTML5-based javascript plugin which crops the image in the canvas element, converts the canvas to a blob and uploads it as png or jpeg to the server by AJAX. It doesn't need any server-side code at all, but it can only run in those browsers which support HTML 5.
EDIT: The link to the plugin has expired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With