Apr-21-2020, 04:10 AM
I am trying this from pypi.org here:
I am getting the error below and I don't know why, as I am trying to follow the pypi.org instructions exactly:
Any idea what the problem is??
from PIL import Image from resizeimage import resizeimage fd_img = open('/home/pedro/backgrounds/pearlReflection.jpg', 'r') img = Image.open(fd_img) img = resizeimage.resize_contain(img, [827, 1169]) img.save('test-image-contain.jpeg', img.format) fd_img.close()I have tried other bits of their code and it worked.
I am getting the error below and I don't know why, as I am trying to follow the pypi.org instructions exactly:
Any idea what the problem is??
Quote:>>> pathTojpgs + jpgFiles[0]
'/home/pedro/backgrounds/pearlReflection.jpg'
>>> fd_img = open('/home/pedro/backgrounds/pearlReflection.jpg', 'r')
>>> fd_img
<_io.TextIOWrapper name='/home/pedro/backgrounds/pearlReflection.jpg' mode='r' encoding='UTF-8'>
>>> img = Image.open(fd_img)
Traceback (most recent call last):
File "<pyshell#66>", line 1, in <module>
img = Image.open(fd_img)
File "/home/pedro/.local/lib/python3.6/site-packages/PIL/Image.py", line 2852, in open
prefix = fp.read(16)
File "/usr/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
>>>