Photologue 3 (and ImageKit)

23 views
Skip to first unread message

Ariel Mauricio Nunez Gomez

unread,
Jan 23, 2009, 11:00:46 AM1/23/09
to pinax-c...@googlegroups.com
  1. #### THE CHAT ####

    Justin (10:47)The big change is that ImageKit moves the "sizes" and "effects" out of the database.
    Justin (10:47)They're defined in external specification modules...
    Ariel (10:47)Where are those?
    Justin (10:47)Anywhere you want. You specify the path to it in your options.
    Ariel (10:47)I see
    Justin (10:47)The spec classes are based on the old photologue Size/Effect classes and are loaded when you start the app.
    Justin (10:47)The nice thing about specs being Python classes too is you can define "global" specs and import them into your spec modules.
    Justin (10:47)Mix and match as you will
    Justin (10:47)The PL3 sample project is built on ImageKit and is a good example of how it's used. I was able to rebuild pl2 using imagekit in less than 30 minutes.
    Justin (10:47)Anyway, I would definately think ImageKit will be a better fit for pinax going forward. It makes no assumptions about your models.
    Ariel (10:48)Thanks a lot
    Ariel (10:48)my connection dropped for a while, but I got all I need here
    unnamed (10:48)is ImageKit a new project that is the "next" version of photologue? (this is brosner btw)
    Ariel (10:48)Photologue is now split
    Ariel (10:48)between basic Image manipulation functionality
    Ariel (10:48)ImageKit
    Ariel (10:49)and Photologue 3
    unnamed (10:49)oh ok i see.
    Ariel (10:49)So, what we are using in Pinax
    Ariel (10:49)(only the photologue basics)
    Ariel (10:49)corresponds better to ImageKit
    Justin (10:49)Hi brosner
    unnamed (10:49)hey justin
    unnamed (10:50)where has development occurred on PL3?
    Justin (10:50)Yeah, imagekit is the core what used to be photologue. It doesn't define a "photo" model or gallery or any of that. You create your own models and ImageKit works behind them to provide the resizing, effects, etc.
    Justin (10:51)PL3 is a branch on the photologue project site. I'm working on ImageKit right now on Bitbucket: http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home
    Justin (10:51)PL3 is just PL2 right now but built on top of ImageKit
    unnamed (10:52)ok excellent. i am going to add this to the list of sprint items we should look at this weekend. are you going to be around justin?
    Justin (10:53)Yeah, on and off. I'm on gtalk and aim as justin....@gmail.com
    unnamed (10:54)ok great. it sounds like you've made some good improvements for PL
    Justin (10:54)Another nice thing about the ImageKit is you can define your own PIL processors. So if you want to implement you own watermarks, or effects it's just a matter of defining a methed that takes a PIL image and returns it after processing.
    Justin (10:55)Opens it up to plugins as it were without requiring database schema changes.
    Justin (10:55)That was the big problem with defining effects in the database. New effect = new schema.
    Ariel (10:58)I am gonna save this chat session and send it to the mailing list, is that ok for you guys?


    #######  THE CODE ########


    from ImageKit import ImageModel
  2.  
  3.  
  4. class Image(ImageModel):
  5.     """
  6.    A photo with its details
  7.    """
  8.     SAFETY_LEVEL = (
  9.         (1, _('Safe')),
  10.         (2, _('Not Safe')),
  11.     )
  12.     crop_horz_choices = (
  13.         (0'left'),
  14.         (1'center'),
  15.         (2'right'),
  16.     )
  17.     crop_vert_choices = (
  18.         (0'top'),
  19.         (1'center'),
  20.         (2'bottom'),
  21.     )
  22.     image_file = models.ImageField(_('image'), upload_to='images')
  23.     view_count = models.IntegerField(default=0)
  24.     crop_horz = models.PositiveIntegerField(_('crop horizontal'),
  25.                                             choices=crop_horz_choices,
  26.                                             default=1)
  27.     crop_vert = models.PositiveIntegerField(_('crop vertical'),
  28.                                             choices=crop_vert_choices,
  29.                                             default=1)
  30.     title = models.CharField(_('title'), max_length=200)
  31.     title_slug = models.SlugField(_('slug'))
  32.     caption = models.TextField(_('caption'), blank=True)
  33.     date_added = models.DateTimeField(_('date added'), default=datetime.now, editable=False)
  34.     is_public = models.BooleanField(_('is public'), default=True, help_text=_('Public photographs will be displayed in the default views.'))
  35.     member = models.ForeignKey(User, related_name="added_photos", blank=True, null=True)
  36.     safetylevel = models.IntegerField(_('safetylevel'), choices=SAFETY_LEVEL, default=1)
  37.     photoset = models.ManyToManyField(PhotoSet, verbose_name=_('photo set'))
  38.     tags = TagField()
  39.    
  40.     class IKOptions:
  41.         spec_module = 'myapp.specs'
  42.         image_field = 'image_file'
  43.         save_count_as = 'view_count'
  44.  
  45.     def __unicode__(self):
  46.         return self.title
  47.  
  48.     def get_absolute_url(self):
  49.         return ("photo_details"[self.pk])
  50.     get_absolute_url = models.permalink(get_absolute_url)
  51.    
  52.    
  53.    
  54. ####### SAMPLE SPEC MODULE #######
  55.  
  56. """ Default Photologue image specifications """
  57.  
  58. from imagekit.specs import ImageSpec
  59. from imagekit import processors
  60.    
  61. # First we define our "processors". ImageKit ships with four configurable
  62. # processors: Adjustment, Resize, Reflection and Transpose. You can also
  63. # create your own processors. Processors are configured by subclassing and
  64. # overriding specific class variables.
  65.  
  66. class ResizeThumbnail(processors.Resize):
  67.     width = 100
  68.     height = 75
  69.     crop = True
  70.    
  71. class ResizeDisplay(processors.Resize):
  72.     width = 600
  73.    
  74. class EnhanceSmall(processors.Adjustment):
  75.     contrast = 1.2
  76.     sharpness = 1.1
  77.    
  78. # Next we define our specificationsd or "specs". Image specs are where we define
  79. # the individual "classes" of images we want to have access to. Like processors
  80. # image specs are configured by subclasses the ImageSpec superclass.
  81.    
  82. class AdminThumbnail(ImageSpec):
  83.     access_as = 'admin_thumbnail'
  84.     processors = [ResizeThumbnail, EnhanceSmall]
  85.  
  86. class Display(ImageSpec):
  87.     increment_count = True
  88.     processors = [ResizeDisplay]
  89.        
  90. class Thumbnail(ImageSpec):
  91.     processors = [ResizeThumbnail, EnhanceSmall]
  92.     pre_cache = True




Ariel Mauricio Nunez Gomez

unread,
Jan 23, 2009, 11:04:49 AM1/23/09
to pinax-c...@googlegroups.com
BTW, I don't know how for long the session is save here, but here is the link:


Spelling mistakes from anyone are on my own, since I was in charge of fixing them, and didn't. :)


greg newman

unread,
Jan 23, 2009, 11:16:37 AM1/23/09
to pinax-c...@googlegroups.com
Thanks for posting this.  I was unable to keep a connection in the chat and it didn't load any of this.



Reply all
Reply to author
Forward
0 new messages