mantidimaging.gui.utility.gif_utils module#
Module containing utility functions for GIF export such as size estimation and optimal frame skip calculation to balance file size and angular resolution.
- mantidimaging.gui.utility.gif_utils.calculate_optimal_frame_skip(projection_count: int, image_height: int, image_width: int, angle_count: int | None = None, max_size_mb: float = 5.0) int[source]#
Calculate optimal frame skip (step size) for GIF export.
Balances the following constraints: - Angular resolution (avoid skipping more than 1 frame per degree) - File size limit (default 5MB)
- Parameters:
projection_count – Total number of projections in the stack
image_height – Height of each image frame (needed for size estimation)
image_width – Width of each image frame (needed for size estimation)
angle_count – Number of unique angles (if None, assumes num_projections = num_angles)
max_size_mb – Maximum GIF file size in MB (default 5.0)
- Returns:
Recommended frame_skip value (step size)
- mantidimaging.gui.utility.gif_utils.estimate_gif_size(frame_count: int, image_height: int, image_width: int) float[source]#
Roughly estimate compressed GIF file size in MB.
Tries to empirically derive compression ratio from GIF LZW compression testing with flower imagestack IMAT00010675 (~0.85f).
Duration is excluded from estimation as it has negligible effect on file size.
- Parameters:
frame_count – Number of frames in the GIF
image_height – Height of each frame in pixels
image_width – Width of each frame in pixels
- Returns:
Estimated file size in MB