RSGISLib Image Tools

Animate Images

rsgislib.tools.imagetools.animate_img_set(input_imgs: List[str], output_img: str, fps: int = 1, resize: bool = False, out_x_size: int = 720, out_y_size: int = None, tmp_dir: str = './tmp')

A function which uses the imageio module to animate a set input images to create an animated GIF video file. This is intended to be used to a set of images which have been exported (e.g., from the mapping module).

The input images can be resampled to a new size but this requires the PIL module to be installed.

Parameters:
  • input_imgs – list of input image paths

  • output_img – output image file path.

  • fps – the number of frames per second. Higher values will result in faster video (i.e., less time per frame). Default: 1.

  • resize – boolean specifying whether to resize the input images.

  • out_x_size – the size of the output image (if resizing) for the x axis. Default: 720

  • out_y_size – the size of the output image (if resizing) for the y axis. If None then the size is calculated from the input image to keep the proportions the same. Default: None

  • tmp_dir – a temp path for the resized images to be written to if resizing the input images.

EXIF Metadata

rsgislib.tools.imagetools.list_exif_info(input_img: str)

A function which prints the exif information from an input image to the console using the exiftool module.

Parameters:

input_img – the path to the input image

rsgislib.tools.imagetools.get_exif_info(input_img: str) Dict

A function which returns a dict of the exif information from an input image using the exiftool module.

Parameters:

input_img – the path to the input image

Returns:

dict of exif data

rsgislib.tools.imagetools.list_exif_info_pil(input_img: str)

A function which prints the exif information from an input image to the console using the PIL module.

Parameters:

input_img – the path to the input image

PDF Utilities

rsgislib.tools.imagetools.extract_images_from_pdf(input_pdf: str, output_dir: str)

A function which extracts the images from a PDF file and files them to a directory as PNG image files.

Note this function requires the fitz module to be installed:

pip install fitz

The fitz module also requires the PyMuPDF module which is not installed by pip.

pip install PyMuPDF

Parameters:
  • input_pdf – the path to the input PDF file.

  • output_dir – the output directory where the images will be stored.

rsgislib.tools.imagetools.add_pdf_blank_pages(input_pdf: str, output_pdf: str)

A function which adds a blank page after each page within the existing PDF document.

Parameters:
  • input_pdf – the input PDF file.

  • output_pdf – the output PDF file.

QR Codes

rsgislib.tools.imagetools.create_qr_code(output_img: str, qr_data: str, qr_code_size: int = 10, qr_code_border: int = 4)

A function which uses the qrcode module to create a QR code image file. Needs the qrcode module installed (pip install qrcode)

Parameters:
  • output_img – file path to the output image

  • qr_data – the data to be encoded in the QR code (e.g., URL)

  • qr_code_size – the size of the QR code (default: 10)

  • qr_code_border – the border to the QA code (default: 4)