I want to add a feature for image cropping in django admin site. I have no idea about that how could I approach this to get it done. I have used django-image-cropping application, but not able to integrate this for admin side.
Asked
Active
Viewed 3,236 times
0
-
Related: http://stackoverflow.com/questions/7907803/django-app-for-image-crop-using-a-cropping-tool . – Juho Vepsäläinen Apr 02 '12 at 10:56
-
have gone through this but not have an idea to implement in django admin side. – PythonDev Apr 02 '12 at 11:04
-
4You need to go back and accept some answers for your previous 8 questions – Timmy O'Mahony Apr 02 '12 at 11:26
-
"not able to integrate" is ... not really precise. If you are using django 1.4 you have to use the latest version (http://pypi.python.org/pypi/django-image-cropping) as it includes some necessary fixes. Otherwise you have to give more information about what's going wrong. As image-cropping was designed for cropping images in the admin you don't really have to *integrate* it. Just follow the docs. – arie Apr 02 '12 at 14:01
-
thanks to all for your valuable suggestion... I have done it using django-cropper app. – PythonDev Apr 02 '12 at 15:06
1 Answers
3
You should define save() method in your model:
class MyImage(models.Model):
image = models.ImageField(...)
image_crop = models.ImageField(blank=True)
def save():
super(MyImage, self).save() #will save only image, image_corp will be blank.
image_path = self.image.path #path to your non croped image
#now you can load image file and crop it usung PIL and save.
self.image_crop = 'path/to/cropped/image' #add path to cropped image.
super(MyImage, self).save() #save data.

qraq
- 318
- 3
- 11