Reputation: 36290
I used PIL to resize image before saving but forgot that the clients uploading the images (sometimes really big images), have to wait a long time before the image is transferred to the server.
I figured the best way to do this is via client-side, probably with html5 and JavaScript. I found this: http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/ but it shows no working example and does not show it in Django tempting language context. I also found this:
Image resize before upload and it says it works in toolkit and Mozilla browsers.
Is there a JavaScript library out there that does this and works with IE as well? Is there a Django templating language example out there?
Upvotes: 1
Views: 1971
Reputation: 2866
Are you uploading images by submitting a form? This: http://blueimp.github.io/jQuery-File-Upload/ will display a progress bar in the browser, and can resize images in the client using Javascript. It is also cross browser compatible.
However, it does require implementing ajax in django, and the styling uses jquery-ui which may not fit into the rest of your design.
I can post some example code if that would help, there is an example django project here: https://github.com/sigurdga/django-jquery-file-upload, or an example on SO: How to add image into a post in django.
Upvotes: 1