
    iN                        d Z 	 ddlZddlZd Zde_        ddlmZ ddZe sej                  ZddZee_        yy# e$ rC 	 ddlmZ ddlZd Zde_        n*# e$ r" 	 ddl	m
Z
 d	 Zd
e_        n# e$ r dZ Y nw xY wY nw xY wY lw xY w)T    Nc                    t        |d         t        |d         }}|| j                  d   kD  s|| j                  d   kD  rt        j                  }nt        j                  }t        j
                  | j                  d      ||f|      S )Nr      uint8)interpolation)intshapecv2INTER_LINEAR
INTER_AREAresizeastype)picnewsizelxlyr   s        U/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/moviepy/video/fx/resize.pyresizerr      sx    WQZ#gaj/B		!SYYq\ 1,,M  NNMzz3::g..R(57 	7    r	   )Imagec                 F   t        t        t        |            d d d   }| j                  }t	        |      dk(  r|d   |d   |d   f}n
|d   |d   f}t        j                  |       }|j                  |d d d   t
        j                        }t        j                  |      S )N   r   r      )listmapr   r   lenr   	fromarrayr   	ANTIALIASnparray)r   r   r   newshapepilimresized_pils         r   r   r      s    3sG,-dd3GIIE5z1}#AJwqz58=#AJwqz2OOC(E,,wtt}eooFK 88K((r   PIL)imresizec           
      B    t        | t        t        |d d d               S )Nr   )r%   r   r   r   r   s     r   <lambda>r(   0   s     HS,/WTrT],C-E r   ScipyFapply_to_maskc                 2  	
 | j                   \  Vfd
t        d      r;
fd	| j                  r	fd}n	fd}| j                  |d|rdg      S g       S  
      nU)t        d      rfd	}t	        | |      S z  z  gn*(t        d      rfd
}t	        | |      S z  z  g| j                  rfd}nfd}| j                  |      }|r)| j                  t	        | j                  d      |_        |S )a   
    Returns a video clip that is a resized version of the clip.
    
    Parameters
    ------------
    
    newsize:
      Can be either 
        - ``(width,height)`` in pixels or a float representing
        - A scaling factor, like 0.5
        - A function of time returning one of these.
            
    width:
      width of the new clip in pixel. The height is then computed so
      that the width/height ratio is conserved. 
            
    height:
      height of the new clip in pixel. The width is then computed so
      that the width/height ratio is conserved.
    
    Examples
    ----------
             
    >>> myClip.resize( (460,720) ) # New resolution: (460,720)
    >>> myClip.resize(0.6) # width and heigth multiplied by 0.6
    >>> myClip.resize(width=800) # height computed automatically.
    >>> myClip.resize(lambda t : 1+0.02*t) # slow swelling of the clip
    
    c                 H    t        | t        t        f      r
| z  | z  gS | S N)
isinstancer   float)nshws    r   trans_newsizezresize.<locals>.trans_newsize`   s)    "sEl+QQ''	r   __call__c                        |             S r.    )tr   r4   s    r   r(   zresize.<locals>.<lambda>i   s    -
"; r   c                 d    dt        d | |      z  j                  d       |            z  dz  S )N      ?   r   r   r   gfr8   newsize2s     r   r(   zresize.<locals>.<lambda>m   s8    Cr!u0D0DW0M19!)> %>>A%B r   c                 R    t         | |      j                  d       |            S Nr   r<   r=   s     r   r(   zresize.<locals>.<lambda>q   s"    72a5<<+@*21+$7 r   Tmask)keep_durationapply_toc                 2    dt         |             z  z  S Nr:   )r   )r8   r2   heights    r   r(   zresize.<locals>.<lambda>   s    SVAY/1 r   c                      d |       z  z  S rF   r7   )r8   r3   widths    r   r(   zresize.<locals>.<lambda>   s    Sq\!^ r   c                 L    dt        d| z  j                  d            z  dz  S )Nr:   r;   r   g     o@r<   r'   s    r   r(   zresize.<locals>.<lambda>   s'    WcCi%7%7%@'JJ5P r   c                 :    t        | j                  d            S rA   r<   r'   s    r   r(   zresize.<locals>.<lambda>   s    G!4g> r   Fr*   )sizehasattrismaskflr   fl_imagerB   )clipr   rG   rI   r+   funrO   newclipr2   r?   r4   r3   s    ```    @@@@r   r   r   =   s=   > 99DAq	 7J';H{{C7 773d2?vh  J JEG  J J
 $G,G 
	6:&1C$$$
 6zA~v.G		5*%+C$$$!e)a-(
 {{P ?mmBG.diiFNr   c                     t        d      )Nz&fx resize needs OpenCV or Scipy or PIL)ImportError)rQ   r   rG   rI   s       r   r   r      s    BCCr   )NNNT)NNN)resize_possibler	   numpyr   r   originrU   r$   r   
scipy.miscr%   moviepy.decoratorsr+   r   __doc__docr7   r   r   <module>r]      s   2$ 	7 GNN -`F 
..CDFN W   $$	)  	$	$+EG$GN 	$#O	$	$/ $sW   ; BABA=A-,A=-A74A=6A77A=:B<A==BB