
    hT
                     D    S r SSKrSSKrSSKJr   " S S\5      rSS jrg)zO
Utility functions for handling images.

Requires Pillow as you might imagine.
    N)Filec                   >    \ rS rSrSr\S 5       r\S 5       rS rSr	g)	ImageFile   zt
A mixin for use alongside django.core.files.base.File, which provides
additional features for dealing with images.
c                 (    U R                  5       S   $ )Nr   _get_image_dimensionsselfs    J/var/www/html/env/lib/python3.13/site-packages/django/core/files/images.pywidthImageFile.width       ))+A..    c                 (    U R                  5       S   $ )N   r   r
   s    r   heightImageFile.height   r   r   c                     [        U S5      (       d*  U R                  nU R                  5         [        XS9U l        U R                  $ )N_dimensions_cache)close)hasattrclosedopenget_image_dimensionsr   )r   r   s     r   r	   ImageFile._get_image_dimensions   s;    t011KKEIIK%9$%LD"%%%r   )r   N)
__name__
__module____qualname____firstlineno____doc__propertyr   r   r	   __static_attributes__ r   r   r   r      s4    
 / / / /&r   r   c                 ^   SSK Jn  UR                  5       n[        U S5      (       a$  U nUR	                  5       nUR                  S5        O [        U S5      nSn Sn UR                  U5      nU(       d  Oi UR                  U5        UR                   (       a?  UR                   R"                  U(       a  UR%                  5         $ UR                  W5        $ US
-  nM   U(       a  UR%                  5         gUR                  W5        g! [         a     gf = f! [        R                   a.  nUR                  S   R                  S5      (       a   S	nANe S	nAf[        R                   a     N[         a     Nf = f! U(       a  UR%                  5         f UR                  W5        f = f)z
Return the (width, height) of an image, given an open file or a path.  Set
'close' to True to close the file at the end if it is initially in an open
state.
r   )r   readrb)NNTi   zError -5N   )PILr   Parserr   tellseekr   OSErrorr&   feedzliberrorargs
startswithstructRuntimeErrorimagesizer   )	file_or_pathr   PillowImageFilepfilefile_pos
chunk_sizedataes	            r   r   r   #   sg    1 A|V$$99;		!	 d+D #  
99Z(Dt" wwww|| JJLIIh !OJ1 2 JJLIIhM  	 	  ::  66!9''
33<<     JJLIIhsl   D F 9D 
&F F 
DDE>0#EF EE>0F 2	E>;F =E>>F +F,)F)r!   r3   r/   django.core.filesr   r   r   r$   r   r   <module>r@      s&      "& &,6 r   