-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create gif #255
Comments
Hi Veronika thanks for using tyssue! Can you try to type alternatively you can try to use the function defined bellow, that just generates the pngs, and then create the gif manually with another software (like ffmpeg or maybe ImageJ, or even Blender). def create_frames(
history,
output,
num_frames=None,
interval=None,
draw_func=None,
margin=5,
**draw_kwds,
):
"""Creates a set of png frames of the recorded history.
Parameters
----------
history : a :class:`tyssue.History` object
output : path to the output directory
num_frames : int, the number of frames in the gif
interval : tuples, define begin and end frame of the gif
draw_func : a drawing function
this function must take a `sheet` object as first argument
and return a `fig, ax` pair. Defaults to quick_edge_draw
(aka sheet_view with quick mode)
margin : int, the graph margins in percents, default 5
if margin is -1, let the draw function decide
**draw_kwds are passed to the drawing function
"""
if draw_func is None:
if draw_kwds.get("mode") in ("quick", None):
draw_func = quick_edge_draw
else:
draw_func = sheet_view
graph_dir = pathlib.Path(output)
graph_dir.mkdir(parents=True, exist_ok=True)
x, y = coords = draw_kwds.get("coords", history.sheet.coords[:2])
sheet0 = history.retrieve(0)
bounds = sheet0.vert_df[coords].describe().loc[["min", "max"]]
delta = (bounds.loc["max"] - bounds.loc["min"]).max()
margin = delta * margin / 100
xlim = bounds.loc["min", x] - margin, bounds.loc["max", x] + margin
ylim = bounds.loc["min", y] - margin, bounds.loc["max", y] + margin
if interval is None:
start, stop = None, None
else:
start, stop = interval[0], interval[1]
for i, (t, sheet) in enumerate(history.browse(start, stop, num_frames)):
try:
fig, ax = draw_func(sheet, **draw_kwds)
except Exception as e:
print("Droped frame {i}")
if isinstance(ax, plt.Axes) and margin >= 0:
ax.set(xlim=xlim, ylim=ylim)
fig.savefig(graph_dir / f"movie_{i:04d}.png")
plt.close(fig) It would be good to split that function anyway |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I am using OS Monterey and I am trying to install Imagemagick to use to create gifs in tyssue.
I have installed it via installing home-brew first (/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)") and then installed Imagemagick via " brew install imagemagick ".
The installation was successful but tyssue still displays an error - Converting didn't work, make sure imagemagick is available on your system.
Could you please help?
Kind regards,
Veronika
The text was updated successfully, but these errors were encountered: