bashu / django-watermark Goto Github PK
View Code? Open in Web Editor NEWπ Quick and efficient way to apply watermarks to images in django
License: BSD 3-Clause "New" or "Revised" License
π Quick and efficient way to apply watermarks to images in django
License: BSD 3-Clause "New" or "Revised" License
Hi @execut ,
Thanks for your work on maintaining this project!
I saw in https://github.com/bashu/django-watermark/blob/develop/CHANGES that a 0.1.9 release has been tagged. It's not yet on https://pypi.org/project/django-watermark/#history, however. Can you do that, or should we ask someone else?
Thanks in advance!
Regards,
Kees
This is fully functional and awesome using Pillow and the default settings, but what would the process for integrating this with AWS S3?
Whenever I try to display the images onto a template or whatever, the .url renders out as '/file/path/djangoproject/media/<aws_img_url>'. In other words, it looks for it in the filesystem.
Hi,
Am new in django programming, I would like to know how to retain the value from dropdown menu when submitting the form, then come back with errors which shows other field are can't be empty.
Here are my codes:
< Choose {% for group in getcropgroup %} {{group.groupname}} {% endfor %}
Thanks in advance
I apply watermark to images which have different size. On middle size images watermark look nice, on small images it overlay, on big images it is hard to discer. Is there any possibility to set watermark size relatively to target image?
Using this plugin together with sorl thumbnail.
in watermark.py", line 167
changed
watermark.date_updated:
to
watermark_updated = make_aware(watermark.date_updated, get_default_timezone())
if modified >= watermark_updated:
Hi,
Your watermark work perfectly, but there a little error in position
parsing :
At line 139 of watermarker/utils.py, the determine_position
function check if the argument position
passed to the function is a str : it is not, but a unicode string.
You could use basestring checking instead, which support both unicode and str instances.
L139:
elif isinstance(position, basestring):
Good job and thanks !
Hello,
Am getting the following error message when I try to open my connections in mysql workbench.Am using Mysql workbench 6.3 (64 -bits)
The error message:
Your connection attempt failed for user 'root' from your host to server at localhost:3306: Can't connect to MySQL server on '127.0.0.1' (61)
Please:
1 Check that mysql is running on server localhost
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to localhost from your address (mysql rights define what
clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for
localhost connecting from the host address you're connecting from
Help would be much appreciated.
Thank you,
Peter
Make sure example
project works without PYTHONPATH
manipulations
watermark + sorl-thumbnail = awesome
this line should be changed
https://github.com/bashu/django-watermark/blob/develop/watermarker/templatetags/watermark.py#L167
to
if modified >= make_aware(watermark.date_updated, get_default_timezone()):
or it gives django 'time aware' comparison exception.
got this after running python setup.py sdist upload --sign
:
Submitting dist/django-watermark-0.1.7.tar.gz to https://pypi.python.org/pypi
Upload failed (403): You are not allowed to edit 'django-watermark' package information
error: Upload failed (403): You are not allowed to edit 'django-watermark' package information
https://pypi.python.org/pypi?:action=role_form&package_name=django-watermark
PyPi username: bashu
I have a problem with filenames with spaces. I got error:
[Errno 2] No such file or directory: '/path/to/image%20with%20spaces.png'
I solved it by unquoting url on line 98 in file watermarker/templatetags/watermark.py
97 # make sure URL is a string
98 import urllib2
99 url = urllib2.unquote(str(url))
correct line 72 in file site-packages/watermarker/templatetags/watermarker.py
replace this:
mark = mark.resize(scale, resample=Image.ANTIALIAS)
for this:
mark = mark.resize(scale, resample=Image.LANCZOS)
I'm getting the below error after carrying out all the necessary settings. How can I get rid of this? I'm on Windows 7 machine.
IOError at /ham/5/
[Errno 13] Permission denied: 'C:\\Python27\\Scripts\\nate\\media'
Request Method: GET
Request URL: http://127.0.0.1:8000/ham/5/
Django Version: 1.4
Exception Type: IOError
Exception Value:
[Errno 13] Permission denied: 'C:\\Python27\\Scripts\\nate\\media'
Exception Location: C:\Python27\lib\site-packages\PIL\Image.py in open, line 1952
Python Executable: C:\Python27\python.exe
Python Version: 2.7.3
Hi,
I am new python programmer, currently am teaching myself on how to develop python web app using Flask.
I get the following error when i try to install bootstrap framework.
(myproject)Peters-MacBook-Pro:Flask_Application peterngimbwa$ pip install flask-bootstrap
Collecting flask-bootstrap
Using cached Flask-Bootstrap-3.3.5.6.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Flask>=0.8 in ./myproject/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg (from flask-bootstrap)
Collecting dominate (from flask-bootstrap)
Using cached dominate-2.1.12.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in ./myproject/lib/python3.4/site-packages/Werkzeug-0.10.4-py3.4.egg (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in ./myproject/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in ./myproject/lib/python3.4/site-packages/itsdangerous-0.24-py3.4.egg (from Flask>=0.8->flask-bootstrap)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in ./myproject/lib/python3.4/site-packages/MarkupSafe-0.23-py3.4-macosx-10.6-intel.egg (from Jinja2>=2.4->Flask>=0.8->flask-bootstrap)
Building wheels for collected packages: flask-bootstrap, dominate
Exception:
Traceback (most recent call last):
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/lib/python3.4/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/lib/python3.4/site-packages/pip/commands/install.py", line 293, in run
wb.build(autobuilding=True)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/lib/python3.4/site-packages/pip/wheel.py", line 756, in build
ensure_dir(output_dir)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/lib/python3.4/site-packages/pip/utils/init.py", line 70, in ensure_dir
os.makedirs(path)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/bin/../lib/python3.4/os.py", line 227, in makedirs
makedirs(head, mode, exist_ok)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/bin/../lib/python3.4/os.py", line 227, in makedirs
makedirs(head, mode, exist_ok)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/bin/../lib/python3.4/os.py", line 227, in makedirs
makedirs(head, mode, exist_ok)
File "/Users/peterngimbwa/Documents/workspace/Flask_Application/myproject/bin/../lib/python3.4/os.py", line 237, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/peterngimbwa/Library/Caches/pip/wheels/80'
The actual error is :
PermissionError: [Errno 13] Permission denied: '/Users/peterngimbwa/Library/Caches/pip/wheels/80'
Could anyone help me to solve the error.
Thank you
Peter
Hi from below, I wish to apply watermark to dynamically generated images, what will be the code? I see instruction sample code does seem to be compatible. Thanks. Cheers.
{% if object.picture %}
Because it's upload_to=b'watermarks'
and the new migration is created as upload_to='watermarks'
django-watermark==0.1.8
Django==1.8.18
Python 3.5.2
Hi,
This repository seems to lack maintenance, I propose myself as a new maintainer.
Could you give me the right to push in your repository or just transfer it on my account in github?
Thank you
Hi,
When I use "USE_TZ = True" in django.settings, I got the error:
can't compare offset-naive and offset-aware datetimes
watermarker/templatetags/watermark.py
# only return the old file if things appear to be the same
if modified >= watermark.date_updated:
After installation package, I see the error below:
File "lib/python3.8/site-packages/watermarker/models.py", line 5, in <module>
from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from 'django.utils.encoding' (lib/python3.8/site-packages/django/utils/encoding.py)
I think to fix it with the following solution
I would love to use this library, but am getting a 'ImageFieldFile' object has no attribute 'split'
error. Migration was smooth, I have it declared in settings and and loaded it in my template. Any thoughts? Thank you. Below is my code.
{% if category.image %}
<img src="/media/{{ category.image|watermark:"test,opacity=40,tile=1" }}"
alt="{{ category.title }}" title="{{ category.title }}"
class="img-responsive center-block shop-item-img-list-view"/>
{% else %}
<img src="http://placehold.it/350" width="100%">
{% endif %}
Hello,
Why: import Image, ImageEnhance
Instead: from PIL import Image, ImageEnhance
I needed to do this for import directly Image and ImageEnhance:
import sys
from PIL import Image, ImageEnhance
sys.modules['Image'] = Image
sys.modules['ImageEnhance'] = ImageEnhance
OSError: cannot write mode RGBA as JPEG
References:
python-pillow/Pillow#2609
https://www.bountysource.com/issues/46873548-cannot-write-mode-rgba-as-jpeg-4-2-0
Hello,
I successfully installed django-watermark. After setting it up, I load up the webpage. On Chrome browser, it's working fine and images are watermarked. On Mozilla firefox and Opera, it's not displaying any images not even the one I uploaded. After checking the source code, I found out that '' after "watermarked" is the one causing the problem.
<li><img src=/media//photos/watermarked\3bbb94f57f32d2796ea59adc86310a12752f0088.jpg> </li>
Template
<li><img src={{ MEDIA_URL }}/{{post.main_view|watermark:"hall,position=tl,opacity=90"}}> </li>
I've been looking for a way to fix this, yet no success. Please any idea on how I can fix this?
I am sorry but i cant seem to find any reason why this app isn't working for me.
ANY assistance will be greatly appreciated
Hi,
Am getting this error when i try to open/create new connection on mysql workbench
Can't connect to MySQL server on '127.0.0.1' (61) .
I get the same error when I try to open my mysql using this command on my terminal:
$mysql -u root -p -h 127.0.0.1 -P 3306
the error
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61) .
Am using Mac OS X Yosemite 10.10.5
Help would be appreciated
Thank you
Peter
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 3.2.8
Python Version: 3.8.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'watermarker']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template error:
In template /Users/bashu/Projects/django-watermark/example/templates/index.html, error at line 6
get() returned more than one Watermark -- it returned 2!
1 : {% load static watermark %}
2 : <html>
3 : <head></head>
4 : <body>
5 : {% with "/media/scream.jpg" as url_path %}
6 : <img src=" {{ url_path|watermark:"sample,scale=0.5,rotation=5,tile=1,greyscale=1,position=br,opacity=85" }} " />
7 : {% endwith %}
8 : </body>
9 : </html>
10 :
Traceback (most recent call last):
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/core/handlers/base.py", line 204, in _get_response
response = response.render()
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/response.py", line 83, in rendered_content
return template.render(context, self._request)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 170, in render
return self._render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/defaulttags.py", line 516, in render
return self.nodelist.render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 988, in render
output = self.filter_expression.resolve(context)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/template/base.py", line 698, in resolve
new_obj = func(obj, *arg_vals)
File "/Users/bashu/Projects/django-watermark/watermarker/templatetags/watermark.py", line 320, in watermark
return Watermarker()(**params)
File "/Users/bashu/Projects/django-watermark/watermarker/templatetags/watermark.py", line 111, in __call__
watermark = Watermark.objects.get(name=name, is_active=True)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/bashu/.virtualenvs/django-watermark/lib/python3.8/site-packages/django/db/models/query.py", line 439, in get
raise self.model.MultipleObjectsReturned(
Exception Type: MultipleObjectsReturned at /
Exception Value: get() returned more than one Watermark -- it returned 2!
cannot write mode RGBA as JPEG
Request Method: GET
Request URL: http://192.168.1.109:8000/img
Django Version: 2.0.1
Exception Type: OSError
Exception Value:
cannot write mode RGBA as JPEG
Exception Location: /env/project/lib/python3.5/site-packages/PIL/JpegImagePlugin.py in _save, line 607
Python Executable: /env/project/bin/python
Python Version: 3.5.2
Python Path:
['/preject/project',
'/sofrware/pycharm-2017.3/helpers/pydev',
'/preject/project',
'/sofrware/pycharm-2017.3/helpers/pydev',
'/.PyCharm2017.3/system/cythonExtensions',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/env/project/lib/python3.5/site-packages',
'/env/project/lib/python3.5/site-packages/setuptools-28.8.0-py3.5.egg',
'/env/project/lib/python3.5/site-packages/pip-9.0.1-py3.5.egg',
'/sofrware/pycharm-2017.3/helpers/pycharm_matplotlib_backend']
Server time: ζζδΈ, 4 εζ 2018 11:10:43 +0800```
[maybe is problem](https://github.com/python-pillow/Pillow/issues/2609)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.