MCPcopy Create free account
hub / github.com/apache/singa / resize

Function resize

python/singa/image_tool.py:124–133  ·  view source on GitHub ↗

Resize the image to make the smaller side be at the given size

(img, small_size)

Source from the content-addressed store, hash-verified

122
123
124def resize(img, small_size):
125 '''Resize the image to make the smaller side be at the given size'''
126 size = img.size
127 if size[0] < size[1]:
128 new_size = (small_size, int(small_size * size[1] / size[0]))
129 else:
130 new_size = (int(small_size * size[0] / size[1]), small_size)
131 new_img = img.resize(new_size, Image.BILINEAR)
132 # print 'resize to (%d,%d)' % new_size
133 return new_img
134
135
136def scale(img, small_size):

Callers 5

scaleFunction · 0.70
resize_by_listMethod · 0.70
TESTFunction · 0.50
TESTFunction · 0.50
ReadImageMethod · 0.50

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.40
TESTFunction · 0.40