Skip to content

Commit

Permalink
working with v3 api
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkohler committed Jan 26, 2024
1 parent 880e054 commit d3970dd
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions WrightTools/artists/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,23 +1098,22 @@ def stitch_to_animation(images, outpath=None, *, duration=0.5, palettesize=256,
Duration of (each) frame in seconds. Default is 0.5.
palettesize : int (optional)
The number of colors in the resulting animation. Input is rounded to
the nearest power of 2. Default is 1024.
the nearest power of 2. Default is 256.
verbose : bool (optional)
Toggle talkback. Default is True.
"""
# parse filename
if outpath is None:
outpath = os.path.splitext(images[0])[0] + ".gif"
# write
t = wt_kit.Timer(verbose=False)
with t, imageio.get_writer(
outpath, mode="I", duration=duration, palettesize=palettesize
) as writer:
for p in images:
image = imageio.imread(p)
writer.append_data(image)
# finish
if verbose:
interval = np.round(t.interval, 2)
print("gif generated in {0} seconds - saved at {1}".format(interval, outpath))
frames = np.stack([imageio.v3.imread(image) for image in images], axis=0)

imageio.v3.imwrite(
outpath,
frames,
plugin="pillow",
duration=duration*1e3,
loop=0,
palettesize=palettesize
)
return outpath

0 comments on commit d3970dd

Please sign in to comment.