ó
    ùŠÂjW  ã                   ó†   • S SK rS SKJr  S SKJrJr  S SKJr   " S S\R                  R                  R                  5      rg)é    N)ÚImage)ÚQRColorMaskÚSolidFillColorMask)ÚSquareModuleDrawerc                   ór   ^ • \ rS rSr% SrSrSr\\S'   \	r
U 4S jrS rU 4S jrS	 rS
 rSS jrS rSrU =r$ )ÚStyledPilImageé   a  
Styled PIL image builder, default format is PNG.

This differs from the PilImage in that there is a module_drawer, a
color_mask, and an optional image

The module_drawer should extend the QRModuleDrawer class and implement the
drawrect_context(self, box, active, context), and probably also the
initialize function. This will draw an individual "module" or square on
the QR code.

The color_mask will extend the QRColorMask class and will at very least
implement the get_fg_pixel(image, x, y) function, calculating a color to
put on the image at the pixel location (x,y) (more advanced functionality
can be gotten by instead overriding other functions defined in the
QRColorMask class)

The Image can be specified either by path or with a Pillow Image, and if it
is there will be placed in the middle of the QR code. No effort is done to
ensure that the QR code is still legible after the image has been placed
there; Q or H level error correction levels are recommended to maintain
data integrity A resampling filter can be specified (defaulting to
PIL.Image.Resampling.LANCZOS) for resizing; see PIL.Image.resize() for possible
options for this parameter.
The image size can be controlled by `embedded_image_ratio` which is a ratio
between 0 and 1 that's set in relation to the overall width of the QR code.
ÚPNGTÚ
color_maskc                 ó
  >• UR                  S[        5       5      U l        UR                  SUR                  SS 5      5      nUR                  SUR                  SS 5      5      U l        UR                  SUR                  SS5      5      U l        UR                  S	UR                  S
[
        R                  R                  5      5      U l        U R                  (       d"  U(       a  [
        R                  " U5      U l        [        S U R                  R                   5       5      U l        U R                  R                  (       a+  [        / U R                  R                  S S QSP5      U l        [        TU ]<  " U0 UD6  g )Nr   Úembedded_image_pathÚembeded_image_pathÚembedded_imageÚembeded_imageÚembedded_image_ratioÚembeded_image_ratiog      Ð?Úembedded_image_resampleÚembeded_image_resamplec              3   ó&   #   • U  H  nS v •  M	     g7f)r   N© )Ú.0Úis     ÚL/var/www/website/venv/lib/python3.13/site-packages/qrcode/image/styledpil.pyÚ	<genexpr>Ú*StyledPilImage.__init__.<locals>.<genexpr>@   s   é € Ð GÒ,F q¥Ò,Fùs   ‚é   éÿ   )Úgetr   r   r   r   r   Ú
ResamplingÚLANCZOSr   ÚopenÚtupleÚ
back_colorÚpaint_colorÚhas_transparencyÚsuperÚ__init__)ÚselfÚargsÚkwargsr   Ú	__class__s       €r   r'   ÚStyledPilImage.__init__*   s8  ø€ Ø Ÿ*™* \Ô3EÓ3GÓHˆŒà$Ÿj™jØ! 6§:¡:Ð.BÀDÓ#Ió
Ðð %Ÿj™jØ˜fŸj™j¨¸$Ó?ó
ˆÔð %+§J¡JØ" F§J¡JÐ/DÀdÓ$Kó%
ˆÔ!ð (.§z¡zØ%Ø�J‰JÐ/´×1AÑ1A×1IÑ1IÓJó(
ˆÔ$ð ×"×"Ö':Ü"'§*¢*Ð-@Ó"AˆDÔô
 !Ñ G¨D¯O©O×,FÒ,FÓ GÓGˆÔØ�?‰?×+×+Ü$Ð%K t§¡×'AÑ'AÀ"À1Ð'EÐ%KÀsÐ%KÓLˆDÔä‰Ò˜$Ð) &Ó)ó    c                 ó$  • U R                   R                  (       d/  U R                  (       a   SU R                  R                  5       ;   a  SOSnU R                   R                  n[
        R                  " X R                  U R                  4U5      $ )NÚAÚRGBAÚRGB)r   r%   r   Úgetbandsr#   r   ÚnewÚ
pixel_size)r(   r*   Úmoder#   s       r   Ú	new_imageÚStyledPilImage.new_imageF   sn   € ð —‘×0×0Ø×'×'¨C°4×3FÑ3F×3OÑ3OÓ3QÓ,Qñ ð
 ð 	ð —_‘_×/Ñ/ˆ
ä�yŠy˜§¡°·±ÐAÀ:ÓNÐNr-   c                 ól   >• U R                   R                  X R                  5        [        TU ]  5         g ©N)r   Ú
initializeÚ_imgr&   Úinit_new_image)r(   r+   s    €r   r<   ÚStyledPilImage.init_new_imageT   s$   ø€ Ø�‰×"Ñ" 4¯©Ô3Ü‰ÑÕ r-   c                 ó’   • U R                   R                  U R                  5        U R                  (       a  U R	                  5         g g r9   )r   Ú
apply_maskr;   r   Údraw_embedded_image)r(   s    r   ÚprocessÚStyledPilImage.processX   s2   € Ø�‰×"Ñ" 4§9¡9Ô-Ø××Ø×$Ñ$Õ&ð r-   c                 ó  • U R                   (       d  g U R                  R                  u  p[        U5      n[        XR                  -  5      n[        [        US-  5      [        US-  5      -
  U R
                  -  5      U R
                  -  nXD4nXS-  -
  nU R                   nUR                  Xf4U R                  5      nSUR                  5       ;   a  U R                  R                  Xu5        g U R                  R                  Xu5        g )Né   r/   )r   r;   ÚsizeÚintr   Úbox_sizeÚresizer   r2   Úalpha_compositeÚpaste)r(   Útotal_widthÚ_Úlogo_width_ishÚlogo_offsetÚlogo_positionÚ
logo_widthÚregions           r   r@   Ú"StyledPilImage.draw_embedded_image]   sß   € Ø×"×"ØØŸ™Ÿ™‰ˆÜ˜+Ó&ˆÜ˜[×+DÑ+DÑDÓEˆä”�[ 1‘_Ó%¬¨N¸QÑ,>Ó(?Ñ?À4Ç=Á=ÑPÓQØ�m‰mñð 	ð %Ð2ˆØ °¡?Ñ2ˆ
Ø×$Ñ$ˆØ—‘ 
Ð7¸×9UÑ9UÓVˆØ�&—/‘/Ó#Ó#Ø�I‰I×%Ñ% fÕ<à�I‰I�O‰O˜FÕ2r-   c                 ó’   • Uc  UR                  SU R                  5      nSU;   a  US	 U R                  R                  " U4SU0UD6  g )NÚkindÚformat)r   rT   r;   Úsave)r(   ÚstreamrU   r*   s       r   rV   ÚStyledPilImage.savep   sD   € Ø‰>Ø—Z‘Z ¨¯	©	Ó2ˆFØ�VÓØ�v�Ø�	‰	�Š�vÑ7 fÐ7°Ó7r-   c                 ó.   • [        U R                  U5      $ r9   )Úgetattrr;   )r(   Únames     r   Ú__getattr__ÚStyledPilImage.__getattr__w   s   € Ü�t—y‘y $Ó'Ð'r-   )r   r   r   r   r$   r9   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rT   Úneeds_processingr   Ú__annotations__r   Údefault_drawer_classr'   r6   r<   rA   r@   rV   r\   Ú__static_attributes__Ú__classcell__)r+   s   @r   r   r      sJ   ø‡ ñð8 €DàÐØÓØ-Ðõ*ò8Oõ!ò'ò
3ô&8÷(ð (r-   r   )Úqrcode.image.baseÚqrcodeÚPILr   Úqrcode.image.styles.colormasksr   r   Ú!qrcode.image.styles.moduledrawersr   ÚimageÚbaseÚBaseImageWithDrawerr   r   r-   r   Ú<module>rp      s/   ðÛ Ý ß JÝ @ôq(�V—\‘\×&Ñ&×:Ñ:õ q(r-   