i.load()
width = min(w, length)
height = int(float(h) * (float(width) / float(w)))
+
+ if c['IMAGE_RESIZE_TO_FIT'] is True:
+ # If it image won't fit in the terminal without scrolling shrink it
+ # Subtract 3 from rows so the tweet message fits in too.
+ h = 2 * (int(rows) - 3)
+ if height >= h:
+ width = int(float(width) * (float(h) / float(height)))
+ height = h
+ if (height <= 0) or (width <= 0):
+ raise ValueError("image has negative dimensions")
+
i = i.resize((width, height), Image.ANTIALIAS)
height = min(height, c['IMAGE_MAX_HEIGHT'])
set_config('IMAGE_ON_TERM', str(c['IMAGE_ON_TERM']))
# Use 24 bit color
c['24BIT'] = args.color_24bit
+ # Resize images based on the current terminal size
+ set_config('IMAGE_RESIZE_TO_FIT', str(c.get('IMAGE_RESIZE_TO_FIT', False)))
# Check type of ONLY_LIST and IGNORE_LIST
if not isinstance(c['ONLY_LIST'], list):
printNicely(red('ONLY_LIST is not a valid list value.'))