o
    Ȑi                     @   sR   d dl Z d dlZd dlZd dlZd dlZd dlZddlmZ d	ddZdd Z	dS )
    N   )ImageFc              
   C   s@  |d u rt jdkratd\}}t| dg}| r5| \}}}	}
|d| d| d|	|  d|
|  g7 }t|d|g  t	|}|
  t| | r_||	| |
| f}|  |S |S t jdkrtj||\}}}td||d	d
|d d d d@ d}| r|\}}| \}}}	}
||| || |	| |
| f}|S ztjjsd}t|tj|\}}W nP ty   |d u rt jdvrtdrtd\}}t| tdd|g t	|}|
  t| | r|| }|  | Y S | Y S  w td||d	d|d d d}| r|| }|S )Ndarwin.pngZscreencapturez-R,z-xwin32RGBrawZBGRr      z$Pillow was built without XCB support)r   r   zgnome-screenshotz-fZBGRX   r   )sysplatformtempfilemkstemposclose
subprocesscallr   openloadunlinkresizecoreZgrabscreen_win32	frombytescropZHAVE_XCBOSErrorZgrabscreen_x11shutilwhich)ZbboxZinclude_layered_windowsZall_screensZxdisplayfhfilepathargslefttoprightbottomimZ
im_resizedoffsetsizedataZx0Zy0msgZ
im_cropped r,   \/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/PIL/ImageGrab.pygrab   s|   

*




"





r.   c                  C   s  t jdkrItd\} }t|  d| d ddddg}d	g}|D ]}|d
|g7 }q!t| d }t|j	dkrBt
|}|  t| |S t jdkrt
j \}}|dkrdd l}|d|d }	|d dkrx||	d  dd}
n||	d  dd}
|
d |
d S t|trt|}|dkrddlm} ||S |dkrddlm} ||S d S tdrd}n
tdrd}nd }t dr|dv rt!ddg }|" }d |v rd }n	|r|d }nd }dg}|r|#d!|g nt d"r|d#v rg d$}nd%}t$|tj%|d&d'}|j&}|r0|d  d(|'   }t(|t|j)}t
|}|  |S ))Nr   r   z,set theFile to (open for access POSIX file "z" with write permission)tryu6       write (the clipboard as «class PNGf») to theFilezend tryzclose access theFileZ	osascriptz-er   r   fileI   zutf-16le mbcs Zpngr   )PngImagePluginZDIB)BmpImagePluginZWAYLAND_DISPLAYwaylandZDISPLAYx11zwl-paste)r8   Nz-l	image/png-txclip)r9   N)r<   z
-selection	clipboardr;   r:   z-ozDwl-paste or xclip is required for ImageGrab.grabclipboard() on LinuxT)capture_outputz error: )*r   r   r   r   r   r   r   r   statst_sizer   r   r   r   r   Zgrabclipboard_win32structunpack_fromdecodesplitindex
isinstancebytesioBytesIOr5   r6   ZPngImageFiler7   ZDibImageFilegetenvr   r   check_output
splitlinesextendNotImplementedErrorrunstderrstripChildProcessErrorstdout)r    r!   commandsscriptcommandr'   fmtr*   rA   ofilesr6   r7   Zsession_typeoutput	mimetypesmimetyper"   r+   perrr,   r,   r-   grabclipboard`   s   

	












r_   )NFFN)
rH   r   r   r   r   r   r5   r   r.   r_   r,   r,   r,   r-   <module>   s   
D