In Python 3 files should be opened as binary

This commit is contained in:
Venelin Stoykov 2017-05-31 11:07:37 +03:00
parent c3dbb1edf0
commit 755bd34c3e
2 changed files with 3 additions and 3 deletions

View file

@ -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()

View file

@ -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: