U
    [Oh7                     @   s    d Z ddlZdd Zdd ZdS )zs
This module implements all the functions to communicate with other Python
modules (PIL, matplotlib, mayavi, etc.)
    Nc                 C   s
   t | S )zt Transforms a PIL/Pillow image into a numpy RGB(A) image.
        Actually all this do is returning numpy.array(im).)nparray)Zim r   K/var/www/html/venv/lib/python3.8/site-packages/moviepy/video/io/bindings.pyPIL_to_npimage	   s    r   c           	      C   sf   ddl m} || }|  |jjj\}}}}t|t| }}| }tj	|tj
d}|||dS )zF Converts a matplotlib figure to a RGB frame after updating the canvasr   )FigureCanvasAgg)Zdtype   )Zmatplotlib.backends.backend_aggr   ZdrawZfigureZbboxZboundsintZtostring_rgbr   Z
frombufferZuint8Zreshape)	Zfigr   Zcanvaslbwhbufimager   r   r   mplfig_to_npimage   s    r   )__doc__numpyr   r   r   r   r   r   r   <module>   s   	