code: def check_and_read(img_path):
      if os.path.basename(img_path)[-3:].lower() == "gif":
          gif = cv2.VideoCapture(img_path)
          ret, frame = gif.read()
          if not ret:
              logger = logging.getLogger("ppocr")
              logger.info(
                  "Cannot read {}. This gif image maybe corrupted."
              )
              return None, False
          if len(frame.shape) == 2 or frame.shape[-1] == 1:
              frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
          imgvalue = frame[:, :, ::-1]
          return imgvalue, True, False
      elif os.path.basename(img_path)[-3:].lower() == "pdf":
          import fitz
          from PIL import Image
  
          imgs = []
          with fitz.open(img_path) as pdf:
              for pg in range(0, pdf.page_count):
                  page = pdf[pg]
                  mat = fitz.Matrix(2, 2)
                  pm = page.get_pixmap(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.get_pixmap(
                          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)
              return imgs, False, True
      return None, False, False
  
imports: import logging
  import os
  import imghdr
  import cv2
  import random
  import numpy
  import paddle
  import importlib.util
  import sys
  import subprocess
label_desc: Use image node_id 7 for calling a global function with example usage: check_and_read(img_path) and returns: None,  False,  False, imgvalue,  True,  False, None,  False, imgs,  False,  True