Commits

Brad Pitcher committed 68ba81b

more changes for image-kit support

Comments (0)

Files changed (8)

satchmo/apps/product/specs.py

+from imagekit.specs import ImageSpec 
+from imagekit import processors 
+from imagekit.processors import Transpose
+
+# first we define our thumbnail resize processor 
+class ResizeThumb(processors.Resize): 
+    width = 85 
+    height = 85 
+
+# now we define a display size resize processor
+class ResizeDisplay(processors.Resize):
+    width = 501 
+    height = 333
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnhanceThumb(processors.Adjustment): 
+    contrast = 1.2
+    sharpness = 1.1 
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnhanceHover(processors.Adjustment): 
+    contrast = 1.2
+    brightness = 1.5
+    sharpness = 1.1 
+
+class ReflectHover(processors.Reflection):
+    background_color = '#f0fff0';
+    size = 0.1
+    opacity = 0.25
+
+class Thumbnail(ImageSpec): 
+    access_as = 'thumbnail_image' 
+    pre_cache = True 
+    processors = [ResizeThumb, EnhanceThumb, Transpose] 
+
+class Hover(ImageSpec): 
+    processors = [ResizeThumb, EnhanceHover, Transpose, ReflectHover] 
+
+class Display(ImageSpec):
+    increment_count = True
+    processors = [ResizeDisplay, Transpose]
+
+class SampleReflection(processors.Reflection):
+    size = 0.2
+    background_color = "#000000"
+
+class PNGFormat(processors.Format):
+    format = 'PNG'
+    extension = 'png'
+
+class DjangoAdminThumbnail(ImageSpec):
+    access_as = 'admin_thumbnail'
+    processors = [Transpose, ResizeThumb, EnhanceThumb, PNGFormat]

satchmo/apps/satchmo_ext/brand/specs.py

+from imagekit.specs import ImageSpec 
+from imagekit import processors 
+
+# first we define our thumbnail resize processor 
+class ResizeThumb(processors.Resize): 
+    width = 100 
+    height = 75 
+    crop = True
+
+# now we define a display size resize processor
+class ResizeDisplay(processors.Resize):
+    width = 600 
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnchanceThumb(processors.Adjustment): 
+    contrast = 1.2 
+    sharpness = 1.1 
+
+# now we can define our thumbnail spec 
+class Thumbnail(ImageSpec): 
+    access_as = 'thumbnail_image' 
+    pre_cache = True 
+    processors = [ResizeThumb, EnchanceThumb] 
+
+# and our display spec
+class Display(ImageSpec):
+    increment_count = True
+    processors = [ResizeDisplay]

satchmo/apps/satchmo_ext/specs.py

+from imagekit.specs import ImageSpec 
+from imagekit import processors 
+
+# first we define our thumbnail resize processor 
+class ResizeThumb(processors.Resize): 
+    width = 100 
+    height = 75 
+    crop = True
+
+# now we define a display size resize processor
+class ResizeDisplay(processors.Resize):
+    width = 600 
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnchanceThumb(processors.Adjustment): 
+    contrast = 1.2 
+    sharpness = 1.1 
+
+# now we can define our thumbnail spec 
+class Thumbnail(ImageSpec): 
+    access_as = 'thumbnail_image' 
+    pre_cache = True 
+    processors = [ResizeThumb, EnchanceThumb] 
+
+# and our display spec
+class Display(ImageSpec):
+    increment_count = True
+    processors = [ResizeDisplay]

satchmo/apps/satchmo_utils/specs.py

+from imagekit.specs import ImageSpec 
+from imagekit import processors 
+
+# first we define our thumbnail resize processor 
+class ResizeThumb(processors.Resize): 
+    width = 100 
+    height = 75 
+    crop = True
+
+# now we define a display size resize processor
+class ResizeDisplay(processors.Resize):
+    width = 600 
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnchanceThumb(processors.Adjustment): 
+    contrast = 1.2 
+    sharpness = 1.1 
+
+# now we can define our thumbnail spec 
+class Thumbnail(ImageSpec): 
+    access_as = 'thumbnail_image' 
+    pre_cache = True 
+    processors = [ResizeThumb, EnchanceThumb] 
+
+# and our display spec
+class Display(ImageSpec):
+    increment_count = True
+    processors = [ResizeDisplay]

satchmo/apps/satchmo_utils/thumbnail/specs.py

+from imagekit.specs import ImageSpec 
+from imagekit import processors 
+from imagekit.processors import Transpose
+
+# first we define our thumbnail resize processor 
+class ResizeThumb(processors.Resize): 
+    width = 85 
+    height = 85 
+
+# now we define a display size resize processor
+class ResizeDisplay(processors.Resize):
+    width = 501 
+    height = 333
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnhanceThumb(processors.Adjustment): 
+    contrast = 1.2
+    sharpness = 1.1 
+
+# now lets create an adjustment processor to enhance the image at small sizes 
+class EnhanceHover(processors.Adjustment): 
+    contrast = 1.2
+    brightness = 1.5
+    sharpness = 1.1 
+
+class ReflectHover(processors.Reflection):
+    background_color = '#f0fff0';
+    size = 0.1
+    opacity = 0.25
+
+class Thumbnail(ImageSpec): 
+    access_as = 'thumbnail_image' 
+    pre_cache = True 
+    processors = [ResizeThumb, EnhanceThumb, Transpose] 
+
+class Hover(ImageSpec): 
+    processors = [ResizeThumb, EnhanceHover, Transpose, ReflectHover] 
+
+class Display(ImageSpec):
+    increment_count = True
+    processors = [ResizeDisplay, Transpose]
+
+class SampleReflection(processors.Reflection):
+    size = 0.2
+    background_color = "#000000"
+
+class PNGFormat(processors.Format):
+    format = 'PNG'
+    extension = 'png'
+
+class DjangoAdminThumbnail(ImageSpec):
+    access_as = 'admin_thumbnail'
+    processors = [Transpose, ResizeThumb, EnhanceThumb, PNGFormat]

satchmo/apps/satchmo_utils/thumbnail/templates/widget/file.html

-{% load satchmo_thumbnail %}
-{% load admin_modify i18n %}{% if bound_field.original_value %}
-{% trans "Currently" %}: <a href ="{{media_url}}{{ bound_field.original_url}}"> <img src="{{ bound_field.original_url|thumbnail:"width=85" }}" width="85" /></a><br />
-{% trans "Change" %}:{% output_all bound_field.form_fields %}
-{% else %} {% output_all bound_field.form_fields %} {% endif %}

satchmo/apps/satchmo_utils/thumbnail/templatetags/__init__.py

Empty file removed.

satchmo/apps/satchmo_utils/thumbnail/templatetags/satchmo_thumbnail.py

-""" image related filters """
-
-##################################################
-## DEPENDENCIES ##
-
-from django import template
-from django.conf import settings
-from django.template import TemplateSyntaxError
-from satchmo_utils.thumbnail.utils import make_thumbnail, get_image_size
-register = template.Library()
-##################################################
-## FILTERS ##
-
-def thumbnail(url, args=''):
-    """ Returns thumbnail URL and create it if not already exists.
-
-.. note:: requires PIL_,
-    if PIL_ is not found or thumbnail can not be created returns original URL.
-
-.. _PIL: http://www.pythonware.com/products/pil/
-
-Usage::
-
-    {{ url|thumbnail:"width=10,height=20" }}
-    {{ url|thumbnail:"width=10" }}
-    {{ url|thumbnail:"height=20" }}
-
-Parameters:
-
-width
-    requested image width
-
-height
-    requested image height
-
-Image is **proportionally** resized to dimension which is no greather than ``width x height``.
-
-Thumbnail file is saved in the same location as the original image
-and his name is constructed like this::
-
-    %(dirname)s/%(basename)s_t[_w%(width)d][_h%(height)d].%(extension)s
-
-or if only a width is requested (to be compatibile with admin interface)::
-
-    %(dirname)s/%(basename)s_t%(width)d.%(extension)s
-
-"""
-    
-    kwargs = {}
-    if args:
-        if ',' not in args:
-            # ensure at least one ','
-            args += ','
-        for arg in args.split(','):
-            arg = arg.strip()
-            if arg == '': continue
-            kw, val = arg.split('=', 1)
-            kw = kw.lower().encode('ascii')
-            try:
-                val = int(val) # convert all ints
-            except ValueError:
-                raise template.TemplateSyntaxError, "thumbnail filter: argument %r is invalid integer (%r)" % (kw, val)
-            kwargs[kw] = val
-    
-    if ('width' not in kwargs) and ('height' not in kwargs):
-        raise template.TemplateSyntaxError, "thumbnail filter requires arguments (width and/or height)"
-    
-    ret = make_thumbnail(url, **kwargs)
-    if ret is None:
-        ret = url
-
-    if not ret.startswith(settings.MEDIA_URL):
-        ret = settings.MEDIA_URL + ret
-
-    return ret
-   
-#
-register.filter('thumbnail', thumbnail)
-
-def image_width(url):
-    """ Returns image width.
-
-Usage:
-    {{ url|image_width }}
-"""
-    
-    width, height = get_image_size(url)
-    return width
-#
-
-register.filter('image_width', image_width)
-
-def image_height(url):
-    """ Returns image height.
-
-Usage:
-    {{ url|image_width }}
-"""
-    
-    width, height = get_image_size(url)
-    return height
-#
-
-register.filter('image_height', image_height)