ó
O'—^c        
   @   s™   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d „  Z d e d ƒ e d	 ƒ d d
 d d d d d „	 Z	 d S(   iÿÿÿÿN(   t   Image(   t	   ImageDraw(   t
   ImageColor(   t	   ImageFont(   t   ImageOpsc         C   s   t  j |  ƒ S(   N(   R   t   getrgb(   t   name(    (    s9   /tmp/pip-unpacked-wheel-K50F1D/autofixture/placeholder.pyt   <lambda>
   t    t   blackt   greyu   Verdana.ttfi*   u   unict   RGBAu   PNGc         C   s[  |  | f } | r | n d j  |  | ƒ } y t j | d | d | ƒ} Wn t k
 rh t j ƒ  } n Xt j |	 | | ƒ } | j | ƒ } t j d | | ƒ } | d d | d d } | d d | d d } t j	 | ƒ } | j
 | | f | d | d	 | ƒt j | | d
 t j d d ƒ} | j | ƒ t j ƒ  } | j | |
 ƒ | j ƒ  S(   sv   Little spin-off from https://github.com/Visgean/python-placeholder
    that not saves an image and instead returns it.s   {0}x{1}t   sizet   encodingR   i    i   i   t   fontt   fillt   methodt	   centeringg      à?(   g      à?g      à?(   t   formatR   t   truetypet   IOErrort   load_defaultR    t   newt   getsizeR   t   Drawt   textR   t   fitt   BICUBICt   pastet   iot   BytesIOt   savet   getvalue(   t   widtht   heightR   t   fg_colort   bg_colorR   R   t   fontsizeR   t   modet   fmtR   t
   result_imgt	   text_sizet   text_imgt   leftt   topt   drawingt   txt_imgt   file_obj(    (    s9   /tmp/pip-unpacked-wheel-K50F1D/autofixture/placeholder.pyt   get_placeholder_image   s*    !(
   R   t   PILR    R   R   R   R   t	   get_colort   NoneR0   (    (    (    s9   /tmp/pip-unpacked-wheel-K50F1D/autofixture/placeholder.pyt   <module>   s   	