Ë
    †®½g_  ã                   ód   — d dl Z d dlmZ d dlmZ d dlZd dlmZ d dl	m
Z
 e G d„ de
«      «       Zy)é    N)Ú	dataclass)ÚUnion)ÚImage)ÚEffectc                   ób   — e Zd ZU dZdZeeeef   e	d<   dZ
ee	d<   dZee	d<   dZee	d<   d„ Zd	„ Zy)
ÚResizeaö  Effect returning a video clip that is a resized version of the clip.

    Parameters
    ----------

    new_size : tuple or float or function, optional
        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.

    height : int, optional
        Height of the new clip in pixels. The width is then computed so
        that the width/height ratio is conserved.

    width : int, optional
        Width of the new clip in pixels. The height is then computed so
        that the width/height ratio is conserved.

    Examples
    --------

    .. code:: python

        clip.with_effects([vfx.Resize((460,720))]) # New resolution: (460,720)
        clip.with_effects([vfx.Resize(0.6)]) # width and height multiplied by 0.6
        clip.with_effects([vfx.Resize(width=800)]) # height computed automatically.
        clip.with_effects([vfx.Resize(lambda t : 1+0.02*t)]) # slow clip swelling
    NÚnew_sizeÚheightÚwidthTÚapply_to_maskc                 óÜ   — t        t        t        |«      «      }t        j                  |«      }|j                  |t        j                  j                  «      }t        j                  |«      S )zResize the image using PIL.)
ÚlistÚmapÚintr   Ú	fromarrayÚresizeÚ
ResamplingÚLANCZOSÚnpÚarray)ÚselfÚpicr	   Úpil_imgÚresized_pils        ú`/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/video/fx/Resize.pyÚresizerzResize.resizer0   sL   € äœœC Ó*Ó+ˆÜ—/‘/ #Ó&ˆØ—n‘n X¬u×/?Ñ/?×/GÑ/GÓHˆÜx‰x˜Ó$Ð$ó    c                 óp  ‡ ‡‡‡	‡
— |j                   \  Š
Š‰ j                  Æˆˆ
fd„Š	t        ‰ j                  d«      r’ˆ ˆ	fd„Š|j                  rˆˆ fd„}nˆˆ fd„}|j	                  |d‰ j
                  rdgng ¬«      }‰ j
                  rB|j                  6|j                  j                  t        ‰ j                  d	¬
«      g«      |_        |S  ‰	‰ j                  «      ‰ _        nÙ‰ j                  [t        ‰ j                  d«      r!ˆˆ fd„}|j                  t        |«      g«      S ‰
‰ j                  z  ‰z  ‰ j                  g‰ _        nr‰ j                  [t        ‰ j                  d«      r!ˆ ˆ
fd„}|j                  t        |«      g«      S ‰ j                  ‰‰ j                  z  ‰
z  g‰ _        nt        d«      ‚|j                  rˆ fd„}nˆ fd„}|j                  |«      }‰ j
                  rB|j                  6|j                  j                  t        ‰ j                  d	¬
«      g«      |_        |S )zApply the effect to the clip.c                 óP   •— t        | t        j                  «      r
| ‰z  | ‰z  gS | S )zÌReturns a [w, h] pair from `new_size_`. If `new_size_` is a
                scalar, then work out the correct pair using the clip's size.
                Otherwise just return `new_size_`
                )Ú
isinstanceÚnumbersÚNumber)Ú	new_size_ÚhÚws    €€r   Útranslate_new_sizez(Resize.apply.<locals>.translate_new_size=   s,   ø€ ô
 ˜i¬¯©Ô8Ø%¨™M¨9°q©=Ð9Ð9à$Ð$r   Ú__call__c                 ó2   •—  ‰‰j                  | «      «      S )N)r	   )Útr   r&   s    €€r   Úget_new_sizez"Resize.apply.<locals>.get_new_sizeJ   s   ø€ Ù-¨d¯m©m¸AÓ.>Ó?Ð?r   c                 ój   •— ‰j                  d | |«      z  j                  d«       ‰|«      «      dz  S )Néÿ   Úuint8ç     ào@©r   Úastype©Ú	get_framer)   r*   r   s     €€r   ÚfilterzResize.apply.<locals>.filterO   s<   ø€ à ŸL™LØ!$¡y°£|Ñ!3× ;Ñ ;¸GÓ DÁlÐSTÃoóð $ñ$ðr   c                 ó^   •— ‰j                   | |«      j                  d«       ‰|«      «      S ©Nr-   r/   r1   s     €€r   r3   zResize.apply.<locals>.filterY   s,   ø€ Ø#Ÿ|™|Ù% a›L×/Ñ/°Ó8¹,Àq»/ó ð r   TÚmask)Úkeep_durationÚapply_toF)r   c                 óD   •— dt        ‰j                  | «      «      z  ‰z  S ©Nç      ð?)r   r
   )r)   r$   r   s    €€r   ÚfunczResize.apply.<locals>.funcp   s    ø€ Ø¤ T§[¡[°£^Ó!4Ñ4°qÑ8Ð8r   c                 ó2   •— d‰j                  | «      z  ‰z  S r:   )r   )r)   r   r%   s    €€r   r<   zResize.apply.<locals>.func{   s   ø€ Ø §¡¨A£Ñ.°Ñ2Ð2r   z9You must provide either 'new_size' or 'height' or 'width'c                 ól   •— d‰j                  d| z  j                  d«      ‰j                  «      z  dz  S )Nr;   r,   r-   r.   ©r   r0   r	   ©r   r   s    €r   Úimage_filterz"Resize.apply.<locals>.image_filter‹   s:   ø€ àØ—l‘l C¨#¡I×#5Ñ#5°gÓ#>ÀÇÁÓNñOàñðr   c                 óZ   •— ‰j                  | j                  d«      ‰j                  «      S r5   r?   r@   s    €r   rA   z"Resize.apply.<locals>.image_filter”   s!   ø€ Ø—|‘| C§J¡J¨wÓ$7¸¿¹ÓGÐGr   )Úsizer	   ÚhasattrÚis_maskÚ	transformr   r6   Úwith_effectsr   r
   r   Ú
ValueErrorÚimage_transform)r   Úclipr3   Únewclipr<   rA   Únew_clipr*   r$   r&   r%   s   `      @@@@r   ÚapplyzResize.apply7   sæ  ü€ ày‰y‰ˆˆ1à=‰=Ð$õ%ô t—}‘} jÔ1õ@ð —<’<öõð
 Ÿ.™.ØØ"&Ø*.×*<Ò*<˜v™hÀ"ð )ó ð
 ×%Ò%¨$¯)©)Ð*?Ø#'§9¡9×#9Ñ#9Ü §¡¸UÔCÐDó$G”Lð ñ !3°4·=±=Ó A•à[‰[Ð$Üt—{‘{ JÔ/õ9ð ×(Ñ(¬&°«,¨Ó8Ð8ð "# T§[¡[¡°1Ñ!4°d·k±kÐ B•àZ‰ZÐ#Üt—z‘z :Ô.õ3ð ×(Ñ(¬&°«,¨Ó8Ð8ð "&§¡¨Q°·±©^¸aÑ-?Ð @•äØKóð ð <Š<õôHð ×'Ñ'¨Ó5ˆà×Ò $§)¡)Ð"7Ø ŸI™I×2Ñ2Ü˜Ÿ™°UÔ;Ð<óˆHŒMð ˆr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   ÚtupleÚfloatÚcallableÚ__annotations__r
   r   r   r   Úboolr   rM   © r   r   r   r      sH   … ñð< /3€HˆeE˜5 (Ð*Ñ+Ó2Ø€FˆCÓØ€Eˆ3ÓØ€M4Óò%ógr   r   )r!   Údataclassesr   Útypingr   Únumpyr   ÚPILr   Úmoviepy.Effectr   r   rW   r   r   ú<module>r]      s5   ðÛ Ý !Ý ã Ý å !ð ôRˆVó Ró ñRr   