def _long_image_slice(in_filepath, out_filepath, slice_size):
print('<STR_LIT>'.format(in_filepath))<EOL>img = Image.open(in_filepath)<EOL>width, height = img.size<EOL>upper = <NUM_LIT:0><EOL>left = <NUM_LIT:0><EOL>slices = int(math.ceil(height / slice_size))<EOL>count = <NUM_LIT:1><EOL>for slice in range(slices):<EOL><INDENT>if count == slices:<EOL><INDENT>lower = height<EOL><DEDENT>else:<EOL><INDENT>lower = int(count * slice_size)<EOL><DEDENT>bbox = (left, upper, width, lower)<EOL>working_slice = img.crop(bbox)<EOL>upper += slice_size<EOL>new_filepath = _build_sliced_filepath(out_filepath, count)<EOL>working_slice.save(new_filepath)<EOL>count += <NUM_LIT:1><EOL><DEDENT>
Slice an image into parts slice_size tall.