porescene.image module¶
- porescene.image.frames2gif(pth_frames, pth_gif, fps=24, trim=True)[source]¶
Exports an animated GIF from the given frames.
The frames are encoded with the
ffmpegbinary shipped withimageio-ffmpegusing a two-pass palette (palettegen/paletteuse) for good color fidelity. Frame transparency is preserved and the GIF loops indefinitely.- Parameters:
pth_frames (
Iterator[Path]) – Ordered paths of the frame images. The animation follows this order.pth_gif (
Path) – Output path of the GIF file.fps (
int) – Playback speed in frames per second, by default 24.trim (
bool) – IfTrue, the transparent padding common to all frames is cropped away before encoding (see_trim_common_padding()), by defaultTrue.
- Returns:
File path of the written GIF.
- Return type:
- porescene.image.frames2mp4(pth_frames, pth_mp4, fps=24, background=(255, 255, 255), trim=True)[source]¶
Exports an MP4 (H.264) video from the given frames.
The frames are encoded with the
ffmpegbinary shipped withimageio-ffmpegusing thelibx264codec and theyuv420ppixel format for broad player and browser compatibility. MP4 cannot store an alpha channel, so each frame is flattened onto a solidbackgroundcolor.- Parameters:
pth_frames (
Iterator[Path]) – Ordered paths of the frame images. The video follows this order.pth_mp4 (
Path) – Output path of the MP4 file.fps (
int) – Playback speed in frames per second, by default 24.background (
tuple[int,int,int]) – RGB color the (transparent) frames are composited onto, by default white(255, 255, 255).trim (
bool) – IfTrue, the transparent padding common to all frames is cropped away before encoding (see_trim_common_padding()), by defaultTrue.
- Returns:
File path of the written MP4.
- Return type:
- porescene.image.img_add_axes(pth_vis, pth_ax)[source]¶
Combines a visualization image with the axes image.
- Return type:
- porescene.image.img_add_colorbar(pth_vis, pth_cb, align=CompassDirection.SOUTH, orientation=Orientation.HORIZONTAL, *, center_rendering=False)[source]¶
Composites the colorbar next to the visualization image.
- Return type:
- porescene.image.img_pad(pth_img, pad=(0, 0, 0, 0), /, trim=True)[source]¶
Adds padding to the given image
- Parameters:
pth_img (
Path) – Path of the image filepad (
int|float|tuple[int|float,int|float,int|float,int|float]) – Amount of padding to add on each side (top, right, bottom, left), by default (0, 0, 0, 0)trim (
bool) – IfTrue, existing whitespace gets trimmed from the image before padding gets applied, by default True
- Returns:
File path of the padded image.
- Return type: