Commits

Anonymous committed 6540eed

now we have watermarking worked

Comments (0)

Files changed (5)

locale/ru/LC_MESSAGES/django.mo

Binary file added.

locale/ru/LC_MESSAGES/django.po

+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-07-12 21:22+0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: models.py:22
+msgid "Category"
+msgstr "Категория"
+
+#: models.py:23
+msgid "Categories"
+msgstr "Категории"
+
+#: models.py:25 models.py:40
+msgid "Slug"
+msgstr "Метка"
+
+#: models.py:26 models.py:41
+msgid "Title"
+msgstr "Заголовок"
+
+#: models.py:37
+msgid "Image"
+msgstr "Изображение"
+
+#: models.py:38
+msgid "Images"
+msgstr "Изображение"
+
+#: models.py:42
+msgid "Description"
+msgstr "Описание"
+
+#: models.py:43
+msgid "Tags"
+msgstr "Теги"
+
+#: templates/imagestore/category.html:3
+msgid "Gallery -"
+msgstr "Галерея -"
+
+#: templates/imagestore/category.html:7 templates/imagestore/gallery.html:3
+#: templates/imagestore/image.html:4 templates/imagestore/image.html.py:8
+msgid "Gallery"
+msgstr "Галерея"
+
+#: templates/imagestore/category.html:19
+msgid "previous page"
+msgstr "Предыдущая страница"
+
+#: templates/imagestore/category.html:22
+msgid "page"
+msgstr "странца"
+
+#: templates/imagestore/category.html:22
+msgid "of"
+msgstr "из"
+
+#: templates/imagestore/category.html:25
+msgid "next page"
+msgstr "следующая страница"
+
+#: templates/imagestore/image.html:25
+msgid "< previous"
+msgstr "< предыдущая"
+
+#: templates/imagestore/image.html:28
+msgid "next >"
+msgstr "следующая >"
+
+#: templates/imagestore/image.html:38
+msgid "Photographer"
+msgstr "Фотограф"
         extra_thumbnails={
             'icon': {'size': (16, 16), 'options': ['crop', 'upscale'], 'extension': 'jpg'},
             'small': {'size': (70, 70), 'extension': 'jpg'},
+            'preview': {'size': (120, 120), 'extension': 'jpg'},
             'display': {'size': (700, 900), 'extension': 'jpg'},
         },
     )
+from PIL import Image, ImageDraw, ImageFont, ImageTk, ImageEnhance
+
+from django.conf import settings
+
+
+
+def watermark(im, requested_size, opts):
+    width, height = im.size
+    font_scale = settings.IMAGESTORE_FONT_SCALE
+    text = settings.IMAGESTORE_WATERMARK_TEXT
+    font_size = int(font_scale*height)
+    im0 = watermarkit(im, text, font_size)
+    return im0
+
+def watermarkit(image, text, font_size=90, font_name = 'tahoma.ttf', opacity = 0.6, color=(0,0,0), margin=(30,30)):
+    font=ImageFont.truetype(font_name, font_size)
+    im0 = Imprint(image, text, font=font, opacity=opacity, color=color, margin=margin)
+    return im0
+
+def ReduceOpacity(im, opacity):
+    """
+    Returns an image with reduced opacity.
+    Taken from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879
+    """
+    assert opacity >= 0 and opacity <= 1
+    if im.mode != 'RGBA':
+        im = im.convert('RGBA')
+    else:
+        im = im.copy()
+    alpha = im.split()[3]
+    alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
+    im.putalpha(alpha)
+    return im
+
+def Imprint(im, inputtext, font=None, color=None, opacity=0.6, margin=(30,30)):
+    """
+    imprints a PIL image with the indicated text in lower-right corner
+    """
+    if im.mode != "RGBA":
+        im = im.convert("RGBA")
+    textlayer = Image.new("RGBA", im.size, (0,0,0,0))
+    textdraw = ImageDraw.Draw(textlayer)
+    textsize = textdraw.textsize(inputtext, font=font)
+    textpos = [im.size[i]-textsize[i]-margin[i] for i in [0,1]]
+    textdraw.text(textpos, inputtext, font=font, fill=color)
+    if opacity != 1:
+        textlayer = ReduceOpacity(textlayer,opacity)
+    return Image.composite(textlayer, im, textlayer)
+ 
+

templates/imagestore/category.html

 {% block sidebar %}
 {% endblock sidebar %}
 {% block content %}
- 
+
+<h1>{{ category.title }}</h1>
 {% if is_paginated %}
     <div class="pagination">
         <span class="step-links spaced">
 {% endif %}
 
 {% for image in images_list %}
-<a href="{{ image.get_absolute_url }}"><img class="preview" src="{{ image.image.extra_thumbnails.small }}"></a>
+<a href="{{ image.get_absolute_url }}"><img class="preview" src="{{ image.image.extra_thumbnails.preview }}"></a>
 {% endfor %}