Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    easy-thumbnails 1.1

    Download button

    No screenshots available
    Downloads: 635  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Chris Beaven | More programs
    BSD License / FREE
    August 31st, 2012, 18:07 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    easy-thumbnails description

    Easy thumbnails for Django

    easy-thumbnails is a powerful, yet easy to implement thumbnailing application for Django.

    To install this application into your project, just add it to your INSTALLED_APPS setting (and run manage.py syncdb):

    INSTALLED_APPS = (
     ...
     'easy_thumbnails',
    )


    Template usage

    To generate thumbnails in your template, use the {% thumbnail %} tag. To make this tag available for use in your template, use:

    {% load thumbnails %}

    Basic tag Syntax:

    {% thumbnail [source] [size] [options] %}

    source must be a File object, usually an Image/FileField of a model instance.

    size can either be:

     * the size in the format [width]x[height] (for example, {% thumbnail person.photo 100x50 %}) or
     * a variable containing a valid size (i.e. either a string in the [width]x[height] format or a tuple containing two integers): {% thumbnail person.photo size_var %}.

    options are a space separated list of options which are used when processing the image to a thumbnail such as sharpen, crop and quality=90.

    Model usage

    You can use the ThumbnailerField or ThumbnailerImageField fields (based on FileField and ImageField, respectively) for easier access to retrieve (or generate) thumbnail images.

    By passing a resize_source argument to the ThumbnailerImageField, you can resize the source image before it is saved:

    class Profile(models.Model):
     user = models.ForeignKey('auth.User')
     avatar = ThumbnailerImageField(
     upload_to='avatars',
     resize_source=dict(size=(50, 50), crop='smart'),
     )


    Lower level usage

    Thumbnails are generated with a Thumbnailer instance. For example:

    from easy_thumbnails import Thumbnailer

    def square_thumbnail(source):
     thumbnail_options = dict(size=(100, 100), crop=True, bw=True)
     return Thumbnailer(source).get_thumbnail(thumbnail_options)


    By default, get_thumbnail saves the file (using file storage). The source file used to instanciate the Thumbnailer must have a name instance relative to the storage root.

    The ThumbnailFile object provided makes this easy:

    from easy_thumbnails import ThumbnailFile

    # For an existing file in storage:
    source = ThumbnailFile('animals/aarvark.jpg')
    square_thumbnail(source)

    # For a new file:
    picture = open('/home/zookeeper/pictures/my_anteater.jpg')
    source = ThumbnailFile('animals/anteater.jpg', file=picture)
    square_thumbnail(source)



    Product's homepage

    Requirements:

    · Python
    · Django

    What's New in This Release: [ read full changelog ]

    · Added a way to avoid generating thumbnails if they don't exist already (with a signal to deal with them elsewhere).
    · Added a thumbnailer_passive filter to allow templates to use the non-generating thumbnails functionality when dealing with aliases.

      


    TAGS:

    Django thumbnails | thumbnailing application | template thumbnails | Django | thumbnails | template

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM