0

有没有人尝试过同时使用所有这些功能?我只能将其中任何 2 个组合在一起,但不知道如何使用所有 3 个,我绝对需要它。我希望从管理员那里进行免费裁剪(选择图像的哪一部分将显示在结果中),将其加水印并使用一些缩略图别名通过简单的缩略图调整大小/压缩它。

它应该是这样的: {% cropped_thumbnail Event.photo.pure_events_list.url|watermark:"General watermark" "cropping_free" %} Where: pure_events_listis thumbnail alias for easy thumbnails |watermark:"General watermark"is filter to get image of watermarked by url and return new url of watermarked image

提前感谢您的帮助!

4

2 回答 2

1

检查这个模块的easy_thumbnails .. https://pypi.python.org/pypi/django-easy-thumbnails-watermark/0.6.2 PS如果你使用python 3需要在模块中调整几行

于 2016-10-02T10:19:17.673 回答
0

您必须创建新的模板标签:

from image_cropping.templatetags.cropping import cropped_thumbnail
from watermarker.templatetags.watermark import watermark

@register.simple_tag(takes_context=True)
def cropped_watermarked_thumbnail(context, instance, ratiofieldname, **kwargs):
    watermark_params = kwargs.pop('watermark', '')
    cropped_image_url = cropped_thumbnail(context, instance, ratiofieldname, **kwargs)
    return watermark(cropped_image_url, watermark_params)

并在您的模板中使用它:

<img src="{% cropped_watermarked_thumbnail product 'crop' scale=1 upscale=True watermark='Watermark,position=C,opacity=100' %}">
于 2018-03-19T18:30:20.697 回答