Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions av/video/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,22 @@ def to_ndarray(self, channel_last=False, **kwargs):
f"Conversion to numpy array with format `{frame.format.name}` is not yet supported"
)

@staticmethod
def from_image(img):
def set_image(self, img):
"""
Construct a frame from a ``PIL.Image``.
Update content from a ``PIL.Image``.
"""
if img.mode != "RGB":
img = img.convert("RGB")

copy_array_to_plane(img, self.planes[0], 3)

@staticmethod
def from_image(img):
"""
Construct a frame from a ``PIL.Image``.
"""
frame: VideoFrame = VideoFrame(img.size[0], img.size[1], "rgb24")
copy_array_to_plane(img, frame.planes[0], 3)
frame.set_image(img)

return frame

Expand Down
Loading