Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (72 sloc) 3.57 KB

clean-image-crop-uploader (CICU)

clean-image-crop-uploader is a django widget to upload an image via Ajax and crop it using Jcrop. It provides a simple workflow: first one, using modal, (by twitter bootstrap) the image can be uploaded and cropped. Second one, you can see the image cropping preview in the form and finally submit the result.

clean-image-crop-uploader is perfect when you use an ImageField on your model where is necessary to have a specific portion of image. It's easy to configure and to use. You can use different configurations , with fixed aspect ratio or minimal image size.

It works with jQuery = 1.8.3 and twitter bootstrap.


  1. Modal window with upload button:

  1. Modal window with crop area:

  1. Form with preview


  1. Install django-image-cropping using pip. For example:

    pip install clean-image-crop-uploader
  2. Add south and cicu to your INSTALLED_APPS.

  3. run migrate commando to your django project:

    python migrate


  • jQuery = 1.8.3
  • Twitter-Bootstrap


  1. Add into

    (r'^ajax-upload/', include('startproject.cicu.urls'))
  2. Create your model-form and set CicuUploaderInput widget to your imageField

    from cicu.widgets import CicuUploaderInput
    class yourCrop(forms.ModelForm):
        class Meta:
            model = yourModel
            cicuOptions = {
                'ratioWidth': '600',       #fix-width ratio, default 0
                'ratioHeight':'400',       #fix-height ratio , default 0
                'sizeWarning': 'False',    #if True the crop selection have to respect minimal ratio size defined above. Default 'False'
            widgets = {
                'image': CicuUploaderInput(options=cicuOptions)
  3. Download twitter bootstrap to your static file folder.

  4. Add in your form template links to jquery, bootstrap,

        <script src=""></script>
        <link href="{{ STATIC_URL }}css/bootstrap.css" rel="stylesheet" type="text/css"/>
        <script src="{{ STATIC_URL }}js/bootstrap.js"></script>
        {{ }}

Run the example

To run the example inside this package follow these commands:

> cd ./example/
> python syncdb
> python migrate # only if you use South!!!
> python collectstatic
> python runserver domain:8000

Go to examples :

  1. Free crop : <http://domain:8000/cicu-freecrop/>
  2. Fixed aspect ratio: <http://domain:8000/cicu-fixedratio/>
  3. Fixed aspect ratio with minimal size: <http://domain:8000/cicu-warningsize/>