code: def slice(filename, number_tiles=None, col=None, row=None, save=True):
      
      im = Image.open(filename)
      im_w, im_h = im.size
  
      columns = 0
      rows = 0
      if not number_tiles is None:
          validate_image(im, number_tiles)
          columns, rows = calc_columns_rows(number_tiles)
          extras = (columns * rows) - number_tiles
      else:
          validate_image_col_row(im, col, row)
          columns = col
          rows = row
          extras = (columns * rows) - number_tiles
  
  
      tile_w, tile_h = int(floor(im_w / columns)), int(floor(im_h / rows))
  
      tiles = []
      number = 1
      for pos_y in range(0, im_h - rows, tile_h): # -rows for rounding error.
          for pos_x in range(0, im_w - columns, tile_w): # as above.
              area = (pos_x, pos_y, pos_x + tile_w, pos_y + tile_h)
              image = im.crop(area)
              position = (int(floor(pos_x / tile_w)) + 1,
                          int(floor(pos_y / tile_h)) + 1)
              coords = (pos_x, pos_y)
              tile = Tile(image, number, position, coords)
              tiles.append(tile)
              number += 1
      if save:
          save_tiles(tiles,
                     prefix=get_basename(filename),
                     directory=os.path.dirname(filename))
      return tuple(tiles)
docs: Split an image into a specified number of tiles.
  
      Args:
         filename (str):  The filename of the image to split.
         number_tiles (int):  The number of tiles required.
  
      Kwargs:
         save (bool): Whether or not to save tiles to disk.
  
      Returns:
          Tuple of :class:`Tile` instances.