, Python  
 


     ,   roadmap  ,      ,     Python   ,     . ,    ,   ,   :                     Minecraft.

    Pillow,       Tkinter     (Canvas),       Pillow,        :         ,       .     :    ,       ,        .





 

, Python  





Pillow  Photoshop:   20      Minecraft-





 Adobe Photoshop (    CS6        ),    (VSDC Video Editor, Wondershare Filmora, Movavi  Capcut),            .   ,   ,            .          :       ,    ,      ,    .        ,     ,      ( ,    Minecraft     ,      ).

,        .    ,     .       Python.  :     ,           ,    UI Photoshop  .   ?        PIL (Python Imaging Library)   Python Pillow.

 ,  Python     ,       . PIL        ,    .         Pillow,     .  ,      Pillow       PNG,           ,      .  ,      ,   Roadmap,               ,                 ,         .


 

     :   -     ,      .      Photoshop,        ,        (  ).          Python,             (-     ?).

  :        open ().           . ,     original = PIL.Image.open("chto-to.png").      ,         ,       save()  show,    . , ,   : image.save("chto-to.png", format="PNG"),    .

  ?      PNG,     128x128        Godot-.  ?  size,  /      size = (128, 128),      : original.thumbnail(size). Thumbnail, ,     .      .

   ,      ,     format (, PNG)  mode (, RGB).

  RGB?  ,  .  ,          .   ,   ,              ,         .    .

   : ,   .      ,        ,   , ,         . - , - , - .        ,    . RGB     ,       ,    (red, green and blue).

Pillow         split,      merge.   -  (        )  colorize(image, black ="red", white ="yellow").        blend.    ,   : image.convert(" ")  image   .

   .  ,    .  :  -  .


. 

     . ?        :     ( ,    )   (    ).   ,  . ...    !

     ,   ,       ,   .    : /.  ,  ,   .

    :      .       ,        - :         ,    . ,     ,      Photoshop    ,   ,  .

    ,       PNG   RGB   , ,        , ?  ,  ,    .      :

from PIL import Image, ImageFilter, ImageOps, ImageEnhance, UnidentifiedImageError

       ()   RGB.     ?  .

img = Image.open(image_path).convert("RGB")

!  ,    .   ,    ,  (      ),    -     .    ,       .

.

blurred = img.filter(ImageFilter.GaussianBlur(blur_radius))

         (  ),        .

edges = blurred.convert("L").filter(ImageFilter.FIND_EDGES)

   .    convert("L")   -  (   /),   FIND_EDGES (   :  ).  ,  L      -,   .

  ,      ?   ,   ,   .    :

edges = ImageOps.invert(edges)

 invert   -    ,     . ,         , !

  ...  ,   - :

edges = edges.point(lambda x: 0 if x < edge_threshold else 255)

,  ,    !    .          , ?  ,    : ,   edge_threshold (   )   0,   ,      255    .     :           .

  point    ,      .        ,  .

if edge_thickness > 0:

edges = edges.filter(ImageFilter.MinFilter(3))

   . ,      edges.

   .     !


. 

 .         .     ,       .

color = img.filter(ImageFilter.GaussianBlur(blur_radius))

     :

 :

color = ImageEnhance.Color(color).enhance(saturation)

 :

color = ImageEnhance.Contrast(color).enhance(contrast)

    ,       ?    ,  ,  ,    : num_colors=8, saturation=1.6, contrast=1.2, edge_threshold=80, blur_radius=3, edge_thickness=1. threshold  thickness      ,     .

,         ,   !

  ,      :

color = color.quantize(colors=num_colors, method=Image.MEDIANCUT).convert("RGB")

color = color.filter(ImageFilter.MedianFilter(size=5))

,    color.

      quantize     . 

   :       (   num_colors),        .    MEDIANCUT:       (N -)           .     .

    RGB   .

      MedianFilter ( ),    , ,    ,   ,      .        ,   .

         !     edges (, )  color ().

  :

result = Image.composite(color, Image.new("RGB", img.size, "black"), edges)

:   ( ,        ,  ).     /.




         Minecraft?   ?

     .       (-  Minecraft      ,      ).  ,       !   .

,   ,           ,    ,  ,    (     ,    Python Pillow).

: pixel_size: int = 16, num_colors: int = 24, saturation: float = 1.3, contrast: float = 1.2.




  .


   .

   ,     (https://www.litres.ru/book/timur-dzhafarovich-agaev/grafika-python-i-ii-74734442/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


