{"id":316033,"date":"2021-01-06T21:00:20","date_gmt":"2021-01-06T21:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316033"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316033","title":{"rendered":"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0445 Github \u0430\u0432\u0430\u0442\u0430\u0440\u043e\u043a"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438 \u043a\u0430\u043a \u043d\u0430 Github.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/38b\/b4f\/59b\/38bb4f59b2f4ef59fbae546dbc239b2f\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0438\u043a\u0430 &quot;test1&quot;\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0438\u043a\u0430 &quot;test1&quot;\" width=\"420\" height=\"420\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0438\u043a\u0430 &#171;test1&#187;<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0430 \u0441 Github&#8217;\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 (\u0434\u0430\u043b\u0435\u0435, \u0431\u043b\u043e\u043a\u043e\u0432) \u0432 \u0443\u0434\u0430\u0447\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043d\u0430 \u0441\u0435\u0440\u043e\u043c \u0444\u043e\u043d\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cee\/268\/6da\/cee2686dad9a4221694469b5d7f7f8ed\" alt=\"\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435\" title=\"\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435\" width=\"419\" height=\"414\"><figcaption>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435<\/figcaption><\/figure>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435 12 \u043d\u0430 12 \u0431\u043b\u043e\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/985\/4e5\/089\/9854e5089bd8c85ecdcb576106f69738\" alt=\"\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0430\u0432\u0442\u0430\u0440\u043a\u0430 \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u043e\u0432 Github\" title=\"\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0430\u0432\u0442\u0430\u0440\u043a\u0430 \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u043e\u0432 Github\" width=\"420\" height=\"420\"><figcaption>\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0430\u0432\u0442\u0430\u0440\u043a\u0430 \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u043e\u0432 Github<\/figcaption><\/figure>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438 \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 6 \u043d\u0430 12, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0440\u0430\u0437\u0438\u043c \u0438 \u0441\u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 12 \u043d\u0430 12.<\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e \u0436, \u043f\u043e\u0445\u043e\u0436\u0435, \u043f\u043e\u0440\u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u042f \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 python.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/p>\n<pre><code class=\"python\">from PIL import ImageDraw, Image import numpy as np import hashlib<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<pre><code class=\"python\">background_color = '#f2f1f2' s = 'test1'<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u043d\u0430\u0431\u043e\u0440&nbsp;\u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445&nbsp;\u0431\u0430\u0439\u0442. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<pre><code>bytes&nbsp;=&nbsp;hashlib.md5(s.encode('utf-8')).digest()<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u0446\u0432\u0435\u0442&nbsp;\u0438\u0437&nbsp;\u0445\u0435\u0448\u0430<\/p>\n<pre><code class=\"python\">main_color&nbsp;=&nbsp;bytes[:3] main_color&nbsp;=&nbsp;tuple(channel&nbsp;\/\/&nbsp;2&nbsp;+&nbsp;128&nbsp;for&nbsp;channel&nbsp;in&nbsp;main_color)&nbsp;#&nbsp;rgb<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0443&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f&nbsp;\u0431\u043b\u043e\u043a\u043e\u0432, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0430\u0439\u0442\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0430 6 \u043d\u0430 12, \u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u0443 \u043d\u0430\u0441 \u043e\u0434\u0438\u043d \u0431\u0438\u0442, \u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"6 \\cdot 12 \\cdot 1\\text{\u0431\u0438\u0442} = 72 \\text{\u0431\u0438\u0442} = 9 \\text{\u0431\u0430\u0439\u0442}\" alt=\"6 \\cdot 12 \\cdot 1\\text{\u0431\u0438\u0442} = 72 \\text{\u0431\u0438\u0442} = 9 \\text{\u0431\u0430\u0439\u0442}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1af\/07f\/e6f\/1af07fe6ff687d0ad546c89161ca8aaa.svg\" width=\"203\" height=\"17\"><\/p>\n<pre><code class=\"python\">#&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u043e\u0432&nbsp;6&nbsp;\u043d\u0430&nbsp;12 need_color&nbsp;=&nbsp;np.array([bit&nbsp;==&nbsp;'1'&nbsp;for&nbsp;byte&nbsp;in&nbsp;bytes[3:3+9]&nbsp;for&nbsp;bit&nbsp;in&nbsp;bin(byte)[2:].zfill(8)]).reshape(6,&nbsp;12)  #&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0443&nbsp;12&nbsp;\u043d\u0430&nbsp;12 \u0441\u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u043e\u0432\u0430\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 need_color&nbsp;=&nbsp;np.concatenate((need_color,&nbsp;need_color[::-1]),&nbsp;axis=0)<\/code><\/pre>\n<p>\u0420\u0438\u0441\u0443\u0435\u043c&nbsp;\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f&nbsp;\u043f\u043e&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0435&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">img_size = (avatar_size, avatar_size) block_size = avatar_size \/\/ 12 # \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430  img = Image.new('RGB', img_size, background_color) draw = ImageDraw.Draw(img)  for x in range(avatar_size):     for y in range(avatar_size):         need_to_paint = need_color[x \/\/ block_size, y \/\/ block_size]         if need_to_paint:             draw.point((x, y), main_color)<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/p>\n<pre><code class=\"python\">img.show()<\/code><\/pre>\n<p>\u0418 \u0445\u043e\u0431\u0430<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f46\/15a\/fa2\/f4615afa2260556d4224248ef8864cb0\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\" width=\"420\" height=\"420\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/figcaption><\/figure>\n<p>\u0425\u043c\u043c\u043c, \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u043e. \u0410\u0445, \u0434\u0430, \u0437\u0430\u0431\u044b\u043b, \u0441\u0430\u043c\u044b\u0435 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 \u0446\u0432\u0435\u0442\u043d\u044b\u0435.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0440\u0430\u043c\u043a\u0443 \u0438\u0437 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432.<\/p>\n<pre><code class=\"python\">for i in range(12):     need_color[0, i] = 0     need_color[11, i] = 0     need_color[i, 0] = 0     need_color[i, 11] = 0<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/523\/cef\/37c\/523cef37c86fc22c959d95a225b7a79e\" width=\"420\" height=\"420\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0443\u0430\u043b\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0438\u043a\u043d\u0435\u0439\u043c\u043e\u0432.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd4\/81f\/020\/fd481f020df6400985d241833ac34151\" alt=\"test2\" title=\"test2\" width=\"420\" height=\"420\"><figcaption>test2<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d0b\/b69\/e40\/d0bb69e404477b917d5bd429471a5f10\" alt=\"test3\" title=\"test3\" width=\"420\" height=\"420\"><figcaption>test3<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fba\/de4\/4fa\/fbade44fae9aeddd9f4a5b09532a0f23\" alt=\"test4\" title=\"test4\" width=\"420\" height=\"420\"><figcaption>test4<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c75\/119\/21a\/c7511921aa469b3c819912e77f569746\" alt=\"test5\" title=\"test5\" width=\"420\" height=\"420\"><figcaption>test5<\/figcaption><\/figure>\n<p>\u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0425\u0430\u0431\u0440\u0430.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/96b\/74c\/9e0\/96b74c9e055de221a7632edf010f70d1\" alt=\"habr\" title=\"habr\" width=\"420\" height=\"420\"><figcaption>habr<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/996\/501\/2aa\/9965012aa64689e647fc647aecf63ef8\" alt=\"ufo\" title=\"ufo\" width=\"420\" height=\"420\"><figcaption>ufo<\/figcaption><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b, \u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0432 \u0441\u0432\u043e\u0439 <a href=\"https:\/\/github.com\/avdosev\/github_avatars_generator\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a> \u0441\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/536310\/\"> https:\/\/habr.com\/ru\/post\/536310\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438 \u043a\u0430\u043a \u043d\u0430 Github.<\/p>\n<figure class=\"\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0438\u043a\u0430 &#171;test1&#187;<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0430 \u0441 Github&#8217;\u0430. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 (\u0434\u0430\u043b\u0435\u0435, \u0431\u043b\u043e\u043a\u043e\u0432) \u0432 \u0443\u0434\u0430\u0447\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043d\u0430 \u0441\u0435\u0440\u043e\u043c \u0444\u043e\u043d\u0435.<\/p>\n<figure class=\"\"><figcaption>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435<\/figcaption><\/figure>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0435 12 \u043d\u0430 12 \u0431\u043b\u043e\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><figcaption>\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0430\u0432\u0442\u0430\u0440\u043a\u0430 \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u043e\u0432 Github<\/figcaption><\/figure>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u0434\u0443\u043c\u0430\u044e, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438 \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 6 \u043d\u0430 12, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0440\u0430\u0437\u0438\u043c \u0438 \u0441\u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 12 \u043d\u0430 12.<\/p>\n<p>\u041d\u0443 \u0447\u0442\u043e \u0436, \u043f\u043e\u0445\u043e\u0436\u0435, \u043f\u043e\u0440\u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u042f \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 python.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/p>\n<pre><code class=\"python\">from PIL import ImageDraw, Image import numpy as np import hashlib<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<pre><code class=\"python\">background_color = '#f2f1f2' s = 'test1'<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u043d\u0430\u0431\u043e\u0440&nbsp;\u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445&nbsp;\u0431\u0430\u0439\u0442. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435.<\/p>\n<pre><code>bytes&nbsp;=&nbsp;hashlib.md5(s.encode('utf-8')).digest()<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u0446\u0432\u0435\u0442&nbsp;\u0438\u0437&nbsp;\u0445\u0435\u0448\u0430<\/p>\n<pre><code class=\"python\">main_color&nbsp;=&nbsp;bytes[:3] main_color&nbsp;=&nbsp;tuple(channel&nbsp;\/\/&nbsp;2&nbsp;+&nbsp;128&nbsp;for&nbsp;channel&nbsp;in&nbsp;main_color)&nbsp;#&nbsp;rgb<\/code><\/pre>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0443&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f&nbsp;\u0431\u043b\u043e\u043a\u043e\u0432, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u0430\u0439\u0442\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0430 6 \u043d\u0430 12, \u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u043b\u043e\u043a \u0443 \u043d\u0430\u0441 \u043e\u0434\u0438\u043d \u0431\u0438\u0442, \u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">#&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u043e\u0432&nbsp;6&nbsp;\u043d\u0430&nbsp;12 need_color&nbsp;=&nbsp;np.array([bit&nbsp;==&nbsp;'1'&nbsp;for&nbsp;byte&nbsp;in&nbsp;bytes[3:3+9]&nbsp;for&nbsp;bit&nbsp;in&nbsp;bin(byte)[2:].zfill(8)]).reshape(6,&nbsp;12)  #&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0443&nbsp;12&nbsp;\u043d\u0430&nbsp;12 \u0441\u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u043e\u0432\u0430\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 need_color&nbsp;=&nbsp;np.concatenate((need_color,&nbsp;need_color[::-1]),&nbsp;axis=0)<\/code><\/pre>\n<p>\u0420\u0438\u0441\u0443\u0435\u043c&nbsp;\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f&nbsp;\u043f\u043e&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0435&nbsp;\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">img_size = (avatar_size, avatar_size) block_size = avatar_size \/\/ 12 # \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430  img = Image.new('RGB', img_size, background_color) draw = ImageDraw.Draw(img)  for x in range(avatar_size):     for y in range(avatar_size):         need_to_paint = need_color[x \/\/ block_size, y \/\/ block_size]         if need_to_paint:             draw.point((x, y), main_color)<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/p>\n<pre><code class=\"python\">img.show()<\/code><\/pre>\n<p>\u0418 \u0445\u043e\u0431\u0430<\/p>\n<figure class=\"\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/figcaption><\/figure>\n<p>\u0425\u043c\u043c\u043c, \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u043e. \u0410\u0445, \u0434\u0430, \u0437\u0430\u0431\u044b\u043b, \u0441\u0430\u043c\u044b\u0435 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 \u0446\u0432\u0435\u0442\u043d\u044b\u0435.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0440\u0430\u043c\u043a\u0443 \u0438\u0437 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432.<\/p>\n<pre><code class=\"python\">for i in range(12):     need_color[0, i] = 0     need_color[11, i] = 0     need_color[i, 0] = 0     need_color[i, 11] = 0<\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0443\u0430\u043b\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0438\u043a\u043d\u0435\u0439\u043c\u043e\u0432.<\/p>\n<figure class=\"\"><figcaption>test2<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>test3<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>test4<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>test5<\/figcaption><\/figure>\n<p>\u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0425\u0430\u0431\u0440\u0430.<\/p>\n<figure class=\"\"><figcaption>habr<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>ufo<\/figcaption><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b, \u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0432 \u0441\u0432\u043e\u0439 <a href=\"https:\/\/github.com\/avdosev\/github_avatars_generator\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a> \u0441\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/536310\/\"> https:\/\/habr.com\/ru\/post\/536310\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-316033","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=316033"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316033\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}