code: def readImage(image_file) -> list:
      if os.path.basename(image_file)[-3:] == "pdf":
          imgs = []
          with fitz.open(image_file) as pdf:
              for pg in range(0, pdf.pageCount):
                  page = pdf[pg]
                  mat = fitz.Matrix(2, 2)
                  pm = page.getPixmap(matrix=mat, alpha=False)
  
                  # if width or height > 2000 pixels, don't enlarge the image
                  if pm.width > 2000 or pm.height > 2000:
                      pm = page.getPixmap(
                          matrix=fitz.Matrix(1, 1), alpha=False
                      )
  
                  img = Image.frombytes(
                      "RGB", [pm.width, pm.height], pm.samples
                  )
                  img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
                  imgs.append(img)
      else:
          img = cv2.imread(image_file, cv2.IMREAD_COLOR)
          if img is not None:
              imgs = [img]
  
      return imgs
  
imports: import sys
  import tarfile
  import os
  import time
  import datetime
  import functools
  import cv2
  import platform
  import numpy
  import fitz
  from PIL import Image
  from pdf2docx.converter import Converter
  from qtpy.QtWidgets import QApplication, QWidget, QPushButton, QProgressBar, QGridLayout, QMessageBox, QLabel, QFileDialog, QCheckBox
  from qtpy.QtCore import Signal, QThread, QObject
  from qtpy.QtGui import QImage, QPixmap, QIcon
  from ppstructure.predict_system import StructureSystem, save_structure_res
  from ppstructure.utility import parse_args, draw_structure_result
  from ppocr.utils.network import download_with_progressbar
  from ppstructure.recovery.recovery_to_doc import sorted_layout_boxes, convert_info_docx
label_desc: Use image node_id 2 for calling a global function with example usage: readImage(image_file) and returns: imgs