Giter Club home page Giter Club logo

doomer / clean-image-crop-uploader-v3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asaglimbeni/clean-image-crop-uploader

0.0 2.0 0.0 623 KB

Clean Image Crop Uploader (CICU) provides AJAX file upload and image CROP functionalities for ImageFields with a simple widget replacement in the form. It use Modal from twitter-bootstrap.

Home Page: http://asaglimbeni.github.com/clean-image-crop-uploader/

License: Other

Python 20.54% CSS 4.18% JavaScript 74.75% HTML 0.53%

clean-image-crop-uploader-v3's Introduction

clean-image-crop-uploader (CICU)

image

image

image

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.

Screenshot:

  1. Modal window with upload button:

image

  1. Modal window with crop area:

image

  1. Form with preview

image

Installation

  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 manage.py migrate

Dependencies

  • jQuery = 1.8.3
  • Twitter-Bootstrap

Configuration

  1. Add into url.py :

    (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, form.media:

    <head>
    ....
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <link href="{{ STATIC_URL }}css/bootstrap.css" rel="stylesheet" type="text/css"/>
        <script src="{{ STATIC_URL }}js/bootstrap.js"></script>
        {{ form.media }}
    
    ....
    </head>

Run the example

To run the example inside this package follow these commands:

> cd ./example/
> python manage.py syncdb
> python manage.py migrate # only if you use South!!!
> python manage.py collectstatic
> python manage.py 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/>

clean-image-crop-uploader-v3's People

Contributors

asaglimbeni avatar doomer avatar knicholes avatar smamaxs avatar sylvaingd avatar taivo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.