This repository was archived by the owner on Sep 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
This repository was archived by the owner on Sep 22, 2020. It is now read-only.
Size parameter doesn't support omitting length or width #36
Copy link
Copy link
Open
Description
According to the docs at https://python-thumbnails.readthedocs.io/en/latest/creating-thumbnails.html
size – String with the wanted thumbnail size. On the form: 200x200, 200 or x200.
But using the second or third forms causes an exception:
>>> get_thumbnail('d:\\temp\\test.jpg', '200x200', crop='center')
<thumbnails.images.Thumbnail object at 0x0000022108309B08>
>>> get_thumbnail('d:\\temp\\test.jpg', '200x', crop='center')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\__init__.py", line 53, in get_thumbnail
size = engine.parse_size(size)
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\engines\base.py", line 183, in parse_size
return int(size.split('x')[0]), int(size.split('x')[1])
ValueError: invalid literal for int() with base 10: ''
>>> get_thumbnail('d:\\temp\\test.jpg', 'x200', crop='center')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\__init__.py", line 54, in get_thumbnail
thumbnail.image = engine.get_thumbnail(original, size, crop, options)
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\engines\base.py", line 37, in get_thumbnail
image = self.create(original, size, crop, options)
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\engines\base.py", line 58, in create
crop = self.parse_crop(crop, self.get_image_size(image), size)
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\engines\base.py", line 209, in parse_crop
x_offset = self.calculate_offset(x_crop, original_size[0], size[0])
File "C:\Users\USER\Envs\cypress\lib\site-packages\thumbnails\engines\base.py", line 226, in calculate_offset
min(percent * original_length / 100.0, original_length - length / 2) - length / 2)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
Metadata
Metadata
Assignees
Labels
No labels