docs: def stitch_map(tiles, width, height, bbox, dpi):
      """
      Merge tiles together into one image.
  
      Args:
          tiles (list of dict of file): tiles for each layer
          width (float): page width in mm
          height (height): page height in mm
          dpi (dpi): resolution in dots per inch
  
      Returns:
          PIL.Image: merged map.
  
      """
      size = (int(width * dpi_to_dpmm(dpi)), int(height * dpi_to_dpmm(dpi)))
      background = Image.new('RGBA', size, (255, 255, 255))
      for layer in tiles:
          layer_img = Image.new("RGBA", size)
          for (x, y), tile_path in layer.items():
              tile = Image.open(tile_path)
              layer_img.paste(tile, ((x - bbox.min.x) * TILE_SIZE, (y - bbox.min.y) * TILE_SIZE))
          background = Image.alpha_composite(background, layer_img)
      add_scales_bar(background, bbox)
      return background.convert("RGB")