Skip to content

Commit

Permalink
Fix for black screen in movie maker
Browse files Browse the repository at this point in the history
For some reason, Matplotlib's image reader returns an array with ones (bug nglviewer#1021).
Had no time to investigate, changed to PIL implementation (which is used by Matplotlib too)
  • Loading branch information
satary authored May 7, 2023
1 parent 32608fe commit 38231e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nglview/contrib/movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ def interupt(self):
def _base64_to_ndarray(cls, value):
import io
import base64
import matplotlib.image as mpimg
from PIL import Image
import numpy as np
im_bytes = base64.b64decode(value)
im_bytes = io.BytesIO(im_bytes)
# convert to numpy RGB value (for moviepy.editor.VideoClip)
return mpimg.imread(im_bytes, format='PNG')
return np.array(Image.open(im_bytes))

0 comments on commit 38231e0

Please sign in to comment.