
    th                        d dl Z d dlZddlmZmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ dd	d
Z ed           dz  Zd Zd Z G d dej                  Z ej        ej        e            ej        ej        d           d ZdS )    N   )Image	ImageFile)i8)i16be)i32be)o8rawjpeg)r         c                 @    t          t          | z   dd                    S )N)i32PAD)cs    g/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/PIL/IptcImagePlugin.pyir   #   s    a~    c                 n    | D ]#}t          dt          |          z  d           $t                       d S )Nz%02x )end)printr   )r   r   s     r   dumpr   '   s>     ' 'fr!uun#&&&&&	GGGGGr   c                   .    e Zd ZdZdZd Zd Zd Zd ZdS )IptcImageFileIPTCzIPTC/NAAc                 6    t          | j        |                   S )N)r   info)selfkeys     r   getintzIptcImageFile.getint6   s    3   r   c                    | j                             d          }t          |          sdS |d         |d         f}|d         dk    s|d         dk     s|d         dk    rd}t          |          |d	         }|d
k    rd}t	          |          |dk    rd}nA|dk    r+t          | j                             |dz
                      }nt          |d	          }||fS )Nr   )Nr   r      r      	   zinvalid IPTC/NAA file      z%illegal field length in IPTC/NAA file   )fpreadlenSyntaxErrorOSErrorr   i16)r    stagmsgsizes        r   fieldzIptcImageFile.field9   s     GLLOO1vv 	7dAaDj Q44<<3q6A::Q!)Cc""" t#::9C#,,S[[DDCZZTW\\$*--..DDq!99DDyr   c                 .   	 | j                                         }|                                 \  }}|r|dk    rn|r| j                             |          }nd }|| j        v rYt          | j        |         t                    r!| j        |                             |           n"| j        |         |g| j        |<   n
|| j        |<   t          | j        d         d                   }t          | j        d         d                   }d| j        v r$t          | j        d         d                   dz
  }nd}|dk    r
|sd| _	        n+|dk    r|rd	|         | _	        n|d
k    r|rd|         | _	        | 
                    d          | 
                    d          f| _        	 t          | 
                    d                   }n$# t          $ r}	d}
t          |
          |	d }	~	ww xY w|dk    r)d||fdd| j        d         | j        d         ffg| _        d S d S )NT   
   )r'   <   r   r   )r'   A   Lr'   RGBr   CMYK)r'      )r'      )r'   x   zUnknown IPTC image compressioniptc)r*   tellr4   r+   r   
isinstancelistappendr   moder"   _sizeCOMPRESSIONKeyErrorr.   r3   tile)r    offsetr1   r3   tagdatalayers	componentidcompressioner2   s              r   _openzIptcImageFile._openU   s,   	)W\\^^F

IC #.. ',,t,,didind33 ?IcN))'2222&*ing%>DIcNN!(	#	)$ DIg&q)**ty)!,--	diDIg&q)**Q.BBBQ;;y;DIIq[[Y[b	DIIq[[Y[r
DI [[))4;;w+?+??
	&%dkk(&;&;<KK 	& 	& 	&2C#,,A%	&
 '>>+v.Aty|TYq\0RSDIII >s   ! G 
G#GG#c                    t          | j                  dk    s| j        d         d         dk    rt          j                            |           S | j        d         \  }}}|\  }}| j                            |           t          j        d          \  }}t          j	        |          }|dk    r|
                    d| j        z             	 |                                 \  }}	|d	k    rn_|	dk    rX| j                            t          |	d
                    }
|
sn-|
                    |
           |	t          |
          z  }	|	dk    X}|                                 	 t!          j        |          5 }|                                 |j        | _        d d d            n# 1 swxY w Y   	 t          j        |           d S # t(          $ r Y d S w xY w# 	 t          j        |           w # t(          $ r Y w w xY wxY w)Nr   r   rA   F)textr
   zP5
%d %d
255
Tr6   i    )r,   rJ   r   loadr*   seektempfilemkstemposfdopenwriter3   r4   r+   mincloser   openimunlinkr.   )r    typerJ   boxencodingrK   o_fdoutfileor3   r0   _ims               r   rU   zIptcImageFile.load   s@   ty>>Q$)A,q/V";";&++D111)A,dC&V !(e444gIdOOu GG&2333		JD$w((GLLT411 


A ((			 	
				G$$ !


&! ! ! ! ! ! ! ! ! ! ! ! ! ! !	'"""""   	'""""   sf   !G 5!F"G "F&&G )F&*G .G 
GGG<G,+G<,
G96G<8G99G<N)	__name__
__module____qualname__formatformat_descriptionr"   r4   rR   rU    r   r   r   r   2   s\        F#! ! !  8/ / /b% % % % %r   r   z.iimc                 f   ddl }ddlm}m} d}t	          | t
                    r| j        S t	          | |j                  r2| j                            d          }|r|                    d          }nEt	          | |j	                  r0	 | j
        j        |j                 }n# t          t          f$ r Y nw xY w|dS  G d d          } |            } t
          | _        i | _        |                    |          | _        	 |                                  n# t&          t          f$ r Y nw xY w| j        S )	z
    Get IPTC information from TIFF, JPEG, or IPTC file.

    :param im: An image containing IPTC data.
    :returns: A dictionary containing IPTC information, or None if
        no IPTC information block was found.
    r   Nr   )JpegImagePluginTiffImagePlugin	photoshopi  c                       e Zd ZdS )getiptcinfo.<locals>.FakeImageN)rh   ri   rj   rm   r   r   	FakeImagers      s        r   rt   )io ro   rp   rC   r   r   JpegImageFilegetTiffImageFiler1   rL   IPTC_NAA_CHUNKAttributeErrorrI   	__class__BytesIOr*   rR   
IndexError)r_   ru   ro   rp   datarq   rt   s          r   getiptcinfor      s}    III22222222D"m$$ w	B5	6	6 GKK,,	 	)==((D	B5	6	6 	6>/"@ADD) 	 	 	D	 |t        
B BL BGJJtBE




!    7Ns$   B   B43B4 D D)(D))rY   rW   rv   r   r   _binaryr   r   r/   r   r   r	   rH   r   r   r   r   register_openrk   register_extensionr   rm   r   r   <module>r      s6  " 
			                ! ! ! ! ! ! ! ! ! ! ! !      F##beeai    y y y y yI' y y yx  M(- 8 8 8  -v 6 6 63 3 3 3 3r   