{"id":592,"date":"2018-07-12T06:52:38","date_gmt":"2018-07-12T04:52:38","guid":{"rendered":"http:\/\/pythonprogramming.altervista.org\/?p=592"},"modified":"2018-08-27T07:55:17","modified_gmt":"2018-08-27T05:55:17","slug":"installing-pil-on-python-3-7-to-make-thumbnails","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/installing-pil-on-python-3-7-to-make-thumbnails\/","title":{"rendered":"Installing PIL on Python 3.7 to make thumbnails"},"content":{"rendered":"<h2>In this video: PIL or Pillow or how to &#8230; image<\/h2>\n<p><a href=\"http:\/\/pythonprogramming.altervista.org\/installing-pil-on-python-3-7-to-make-thumbnails\/thumbnail\/\" rel=\"attachment wp-att-593\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-593\" src=\"http:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail.png\" alt=\"\" width=\"320\" height=\"236\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail.png 956w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail-320x236.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail-768x566.png 768w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>When you want to work with images in Python, there is nothing better than a pillow&#8230; module. To install it, go into the cmd and type pip install Pillow, like you can see in the video below. In the same video we will show how to&#8230;<\/p>\n<h2>Create a thumbnail with Python and PIL<\/h2>\n<pre class=\"lang:default decode:true \" title=\"Code to make a thumbnail\"># Pythonprogramming.altervista.org\r\n\r\n# code to make a thumbnail\r\n\r\nfrom PIL import Image\r\n\r\nim = Image.open(\"getit.png\")\r\nim.thumbnail((128, 128), Image.ANTIALIAS)\r\nim.save(\"thumbnail.png\", \"PNG\")\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>It&#8217;s very easy to use the PIL \/ Pillow module in Python. Let&#8217;s see a fresh install in Python 3.7, the ultimate Python version (july 2018, now).<\/p>\n<p><iframe loading=\"lazy\" title=\"Python: make a thumbnail from an image with PIL\" width=\"747\" height=\"560\" src=\"https:\/\/www.youtube.com\/embed\/Osm5ze7cSc4?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>The video with only code to thumbnail an image (no installation of PIL)<\/h2>\n<div style=\"width: 747px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-592-1\" width=\"747\" height=\"467\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"http:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail_fast-1.mp4?_=1\" \/><a href=\"http:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail_fast-1.mp4\">http:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2018\/07\/thumbnail_fast-1.mp4<\/a><\/video><\/div>\n<script>\r\nlet title = \"PIL - elaborate images\"\r\nlet links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/add-some-text-as-a-chunk-into-a-png-file-and-recover-it\/\",\"Input and recover text into a png with PIL\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/split-images-with-pil-aka-pillow-and-python-for-sprite-animation\/\",\"Crop Images\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/a-brief-guide-to-pil-python-image-library\/\",\"PIL GUIDE\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/a-matrix-wallpaper-with-python-and-pil-1\/\",\"Matrix wallpaper with PIL\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/cheat-sheet-for-pythons-pil-module\/\",\"Pil Cheat sheet\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/animated-cartoon-gif-with-pil-and-python-1\/\",\"Animated Gif\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/installing-pil-on-python-3-7-to-make-thumbnails\/\",\"Install PIL and make thumbnail\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/make-an-image-with-text-with-python\/\",\"Create an image with text\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/transform-a-png-in-a-thumbnail\/\",\"Make a thumbnail (2)\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/powerpoint-pil-png-animated-gif\/\",\"Gif with Powerpoint and PIL\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/resize-images-with-pil\/\",\"Resize Images\"],\r\n\t\r\n\t];\r\n<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\n","protected":false},"excerpt":{"rendered":"How to create a thumbnail wit PIL module in Python.\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/installing-pil-on-python-3-7-to-make-thumbnails\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":593,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[113,50],"tags":[99,101,161,162,4,163],"class_list":["post-592","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-3-7","category-video","tag-image","tag-images-and-python","tag-pil","tag-pillow","tag-python","tag-python3-7"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":4,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":604,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/592\/revisions\/604"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/593"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}