code: def collect_image_infos(path, exclude_extensions=None):
      img_infos = []
  
      images_generator = scandir(path, recursive=True)
      for image_path in track_iter_progress(list(images_generator)):
          if exclude_extensions is None or (
              exclude_extensions is not None
              and not image_path.lower().endswith(exclude_extensions)
          ):
              image_path = os.path.join(path, image_path)
              img_pillow = Image.open(image_path)
              img_info = {
                  "filename": image_path,
                  "width": img_pillow.width,
                  "height": img_pillow.height,
              }
              img_infos.append(img_info)
      return img_infos
  
file_path: mmdetection/tools/dataset_converters/images2coco.py
imports: import argparse
  import os
  from mmengine.fileio import dump, list_from_file
  from mmengine.utils import mkdir_or_exist, scandir, track_iter_progress
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: collect_image_infos(path, exclude_extensions) and returns: img_infos