
    Rh                        d Z dgZddlmZ ddlmZ  G d de      Zg Zd Zd Z	e	d        Z
e	d	        Ze	d
        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Ze	d        Zy)z/Class representing image/* type MIME documents.	MIMEImage    )encoders)MIMENonMultipartc                   6    e Zd ZdZdej
                  fdddZy)r   z1Class for generating image/* type MIME documents.N)policyc                    |t        |      n|}|t        d      t        j                  | d|fd|i| | j	                  |        ||        y)a  Create an image/* type MIME document.

        _imagedata contains the bytes for the raw image data.  If the data
        type can be detected (jpeg, png, gif, tiff, rgb, pbm, pgm, ppm,
        rast, xbm, bmp, webp, and exr attempted), then the subtype will be
        automatically included in the Content-Type header. Otherwise, you can
        specify the specific image subtype via the _subtype parameter.

        _encoder is a function which will perform the actual encoding for
        transport of the image data.  It takes one argument, which is this
        Image instance.  It should use get_payload() and set_payload() to
        change the payload to the encoded form.  It should also add any
        Content-Transfer-Encoding or other headers to the message as
        necessary.  The default encoding is Base64.

        Any additional keyword arguments are passed to the base class
        constructor, which turns them into parameters on the Content-Type
        header.
        Nz"Could not guess image MIME subtypeimager   )_what	TypeErrorr   __init__set_payload)self
_imagedata_subtype_encoderr   _paramss         '/usr/lib/python3.12/email/mime/image.pyr   zMIMEImage.__init__   s_    * )1(85$h@AA!!$ 	-& 	-$+	-$    )__name__
__module____qualname____doc__r   encode_base64r    r   r   r   r      s    ;,0"00<@r   c                 6    t         D ]  } ||       x}s|c S  y N)_rules)dataruleress      r   r
   r
   2   s*     t*3J r   c                 0    t         j                  |        | S r   )r   append)rulefuncs    r   r   r   :   s    
MM(Or   c                 &    | dd dv ry| dd dk(  ryy)z1JPEG data with JFIF or Exif markers; and raw JPEG   
   )s   JFIFs   ExifjpegN   s   r   hs    r   _jpegr+   ?   s-     	2w$$	
2A%	% 
&r   c                 (    | j                  d      ryy )Ns   PNG

png
startswithr)   s    r   _pngr0   H   s    ||() *r   c                     | dd dv ryy)zGIF ('87 and '89 variants)Nr%   )s   GIF87as   GIF89agifr   r)   s    r   _gifr3   N   s     	!u&& 'r   c                     | dd dv ryy)z-TIFF (can be in Motorola or Intel byte order)N   )s   MMs   IItiffr   r)   s    r   _tiffr7   U   s     	!u r   c                 (    | j                  d      ryy)zSGI image librarys   rgbNr.   r)   s    r   _rgbr:   \        	||K  !r   c                 f    t        |       dk\  r#| d   t        d      k(  r| d   dv r	| d   dv ryy	y	y	y	)
zPBM (portable bitmap)   r      P   s   14r5       	
pbmNlenordr)   s    r   _pbmrE   c   G     1v{aDCI!A$%-AaDJ4F 5G- r   c                 f    t        |       dk\  r#| d   t        d      k(  r| d   dv r	| d   dv ryy	y	y	y	)
zPGM (portable graymap)r=   r   r>   r?   s   25r5   r@   pgmNrB   r)   s    r   _pgmrI   k   rF   r   c                 f    t        |       dk\  r#| d   t        d      k(  r| d   dv r	| d   dv ryy	y	y	y	)
zPPM (portable pixmap)r=   r   r>   r?   s   36r5   r@   ppmNrB   r)   s    r   _ppmrL   s   rF   r   c                 (    | j                  d      ryy)zSun raster files   YjrastNr.   r)   s    r   _rastrO   {   s     	||'( )r   c                 (    | j                  d      ryy)zX bitmap (X10 or X11)s   #define xbmNr.   r)   s    r   _xbmrR      r;   r   c                 (    | j                  d      ryy )Ns   BMbmpr.   r)   s    r   _bmprU      s    ||E r   c                 :    | j                  d      r
| dd dk(  ryy y )Ns   RIFF      s   WEBPwebpr.   r)   s    r   _webprZ      s&    ||G1RG!3 "4r   c                 (    | j                  d      ryy )Ns   v/1exrr.   r)   s    r   _exrr]      s    ||'( )r   N)r   __all__emailr   email.mime.nonmultipartr   r   r   r
   r   r+   r0   r3   r7   r:   rE   rI   rL   rO   rR   rU   rZ   r]   r   r   r   <module>ra      s:  
 6-  4  B 

    
                  
  
  r   