+
    

j-                     b    ^ RI Ht ^ RIHtHt ^ RIHtHt ^ RIt^ RI	H
t
 ^ RIHt R	R R lltR# )
    )remove)
UploadFileHTTPException)Image
ImageColorN)validate_image)save_image_historyc                <    V ^8  d   QhR\         R\        R\         /# )   filebg_colorbackground_file)r   str)formats   "5/var/www/html/photoedit/app/services/image_service.py__annotate__r   y  s+     h
 h

h
h
  h
    c                 f  "   \        V 4      G R j  xL
  V P                  4       G R j  xL
 p \        V4      p\        P                  ! \
        P                  ! V4      4      P                  R4      pRpV'       d   Rp\        V4      G R j  xL
  VP                  4       G R j  xL
 p\        P                  ! \
        P                  ! V4      4      P                  R4      pVP                  VP                  4      p\        P                  ! VV4      p	M^V'       dU   Rp \        P                  ! VR4      p
\        P                  ! RTP                  T
4      p\        P                  ! TT4      p	MTp	\
        P                  ! 4       pV	P!                  VRR	R
7       VP#                  ^ 4       VP%                  4       p\'        RV P(                  VR7      G R j  xL
  V#  EL EL ELY ELD  \         d    \        RRR7      hi ; i L.  \         d    h \         d    \        RRR7      hi ; i5i)NRGBAnoneimagecolori  zInvalid background color)status_codedetailPNGT)r   optimizeguest)
user_phonefilenamebg_typei  zInternal server error)r   readr   r   openioBytesIOconvertresizesizealpha_compositer   getcolor	Exceptionr   newsaveseekgetvaluer	   r   )r   r   r   
input_dataoutput_data
foregroundr    bg_data
backgroundfinal_image	rgb_colorbufferfinal_outputs   &&&          r   remove_image_backgroundr8   y  s     
yy{"J^
Z(ZZJJ{#

'&/ 	 G    ,0022G

7#gfo  $**J  //K
 G&//	 J  //K %K 	 	
 	A( ]]
 	
 	
 q "  34  # #5 D	
   
*
 	

s   H1G H1G#H1AH
 G&H
 %G)&A7H
 H
 !G, 8B!H
 HH
 H1#H1&H
 )H
 ,HH
 
H.H..H1)NN)rembgr   fastapir   r   PILr   r   r#   app.utils.file_validatorr   app.services.history_servicer	   r8    r   r   <module>r?      s0   D 

 

h
 h
r   