Django ImageField that generates multiple renditions - django

In the admin of my Django website I let admins upload images at a very high resolution. I want to automatically generate and store several renditions of each uploaded image at specific sizes, and then use the different sized renditions in different places on the website.
What is a good way to do this?

I ended up using django-imagekit.

You can use the image directly in your template and use sorl to generate the thumbnail or image at different size.
https://djangosnippets.org/snippets/1172/
You can also override the model save method, check this small script:
https://djangosnippets.org/snippets/1172/

Related

Multiple image upload in Django admin for a gallery

I have spent a lot of time trying different ways to upload multiple images in Django admin but I have failed miserably. I have tried django-multiupload-admin which I didn't manage to make it work and inlines is not what I am looking for. I just want to select several images all at once, upload them under one category and them display them into a mansory gallery. I am willing to pay someone to help me find a simple way. Please help!
You can extend the Admin interface pretty easily using Javascript.
Here is the link ... it will help you design django admin with drag and drop method to upload images
Django Snippet Article about Image Upload

django cms and responsive images

I'm building an responsive website with django and django-cms. So far everything is fine. Now I'm at the point that I need to specify and to deliver responsive images to different devices. How do you solve this problem for yourself?
Is there a possibility for the website-author to upload in the backend a picture in different sizes (like small, medium, large) to use with srcset (maybe with django-cascade) Or are there automated solutions for django and django-cms like the php-project adaptive images.
I found django-daguerre but I'm not shure how it can be implemented with django-cms. There is also the django-responsive-images 1.0.2 package.
So I want to ask you how you solve this problem for your projects.
Here's what I do for responsive (and retina) images in djangocms.
I use the THUMBNAIL_HIGH_RESOLUTION = True setting of easy_thumbnails
I use cmsplugin_filer_image for my images. I overwrite its template default.html by adding srcset and Twitter bootstrap's img-responsive class to the img tags in the template.
You could of course also use foundation's interchange, retina.js or your own css/js solution to grab the desired pictures for the respective resolutions.

Upload an image with AJAX, crop portion of our choice, and save in django admin

I need to give the admin the feature of uploading an image for an ImageField using AJAX, and then crop the portion of his choice (with a predefined dimension ratio or resolution) and then save the cropped image in the database.
I tried django-image-cropping and django-ajaximage for this.
#Using django-image-cropping
from image_cropping import ImageRatioField
class Alumnus(models.Model):
photo = models.ImageField(null=True, blank=True)
cropped_photo = ImageRatioField('photo', '430x360')
#Using django-ajaximage
from ajaximage.fields import AjaxImageField
class Alumnus(models.Model):
photo = AjaxImageField(
upload_to='alumni_photos',
max_height=400,
max_width=400,
crop=True
)
While django-ajaximage uploads an image using AJAX, but it doesn't allow the admin to choose which part of the image he wants to be cropped, django-image-cropping crops an image in two steps: first we need to upload an image, save it to the db, then again we need to open the object and select crop portion, and save it again to the database, which i feel is unnecessarily cumbersome. Any suggestions?
It looks like you'll need a JS library in the browser that does the actual cropping. Then you can use AJAX to send it to the server.
DarkroomJS might be just what you need. It uses the HTML5 canvas to do the image editing in browser. It's actually got a few more features than you need, but it should get the job done.
The django-client-side-image-cropping library crops the image on client-side (Using the Croppie Javascript library) to a specific size. It is compatible with django-admin sites. It does not use AJAX. It uses InMemoryUploadedFile to temporarily store the original file.
django-cropper-image is an app I made for client side cropping and compressing uploaded images via Django’s app using with help cropper.js. github link django-cropper-image.
from django.db import models
from django_cropper_image.fields import ImageCropperField
class Images(models.Model):
image = ImageCropperField(upload_to='image',max_length=255)

How to change django FileFiled 'storage' AFTER uploading?

I am developing two web sites using the Django framework.
The thing is - one site is sharing part of the content from the other one.
They both use different amazon WS buckets to store images, etc.
So for the site which shares some content with another one I need to specify a different MEDIA_URL, but it seems impossible cause 'upload_to' and 'storage' parameters of the FileField only influence the file being uploaded.
Is there any way to use another storage when displaying image after it was uploaded?

Django Bulk Zip upload

I want to upload images to a gallery app. I want the user to be able to either load images normaly, or upload on zip file containing all the images for that gallery. Then it must be uncompressed and all images must be added to that model. This is for the admin site.
Any ideas?
You could either use the existing django-app django-photologue which enables you to do that or have a look at how it is implemented there: https://code.google.com/p/django-photologue/source/browse/trunk/photologue/models.py.
If you see that photlogue is lacking some of the functionality you need, you could also subclass and extend photologue's models in your app!