mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
In Python 3 files should be opened as binary
This commit is contained in:
parent
c3dbb1edf0
commit
755bd34c3e
2 changed files with 3 additions and 3 deletions
|
|
@ -144,7 +144,7 @@ on, or what should be done with the result; that's up to you:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
source_file = open('/path/to/myimage.jpg')
|
||||
source_file = open('/path/to/myimage.jpg', 'rb')
|
||||
image_generator = Thumbnail(source=source_file)
|
||||
result = image_generator.generate()
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ example, if you wanted to save it to disk:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
dest = open('/path/to/dest.jpg', 'w')
|
||||
dest = open('/path/to/dest.jpg', 'wb')
|
||||
dest.write(result.read())
|
||||
dest.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ A simple example of a custom source group class is as follows:
|
|||
def files(self):
|
||||
os.chdir(self.dir)
|
||||
for name in glob.glob('*.jpg'):
|
||||
yield open(name)
|
||||
yield open(name, 'rb')
|
||||
|
||||
Instances of this class could then be registered with one or more spec id:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue