{"id":55,"date":"2014-10-13T00:54:29","date_gmt":"2014-10-12T23:54:29","guid":{"rendered":"http:\/\/www.pixnbgames.com\/blog\/?p=55"},"modified":"2015-04-03T09:39:19","modified_gmt":"2015-04-03T08:39:19","slug":"decrease-size-of-png-images-with-pngquant","status":"publish","type":"post","link":"https:\/\/www.pixnbgames.com\/blog\/tratamiento-imagenes\/decrease-size-of-png-images-with-pngquant\/","title":{"rendered":"Decrease size of PNG images with pngquant"},"content":{"rendered":"<p style=\"text-align: justify;\">When we develop software for mobile devices, we have to keep in mind that these devices have reduced specs if we compare its with traditional PCs. An aspect in which we have to put special attention is the program size, because probably many users will decide to install our software depending on it.<\/p>\n<p style=\"text-align: justify;\">In the case of video games, we find that we normally use a large number of images, what will cause our program occupies a large space on disk. Therefore, it&#8217;s interesting to know tools that help us to optimize our program resources.<\/p>\n<h3>pngquant<\/h3>\n<p style=\"text-align: justify;\">While the development of my first video game, I found that the size of my executable file was so large, although my game was nos so long. Searching information about how to reduce this size I came to <a title=\"pngquant\" href=\"http:\/\/pngquant.org\/\" target=\"_blank\">pngquant<\/a>.<\/p>\n<p style=\"text-align: justify;\"><em>pngquant <\/em>is a command line tool, available for OS X, Windows and several GNU\/Linux distributions, that allow us to reduce our PNG images with lossy compression.\u00a0It is an open source library; we can get its code from GitHub. Furthermore, there are some graphics tools which make easiest our work with <em>pngquant<\/em> if we aren&#8217;t confortable with command line. For example,\u00a0<a title=\"TinyPNG site\" href=\"https:\/\/tinypng.com\/\" target=\"_blank\">TinyPNG<\/a> is an utility that allow us to optimize our images directly from its website.<\/p>\n<h4 style=\"text-align: justify;\">How to use\u00a0pngquant<\/h4>\n<p style=\"text-align: justify;\">The first step is to download the tool for our system directly from its website: <a title=\"Sitio oficial pngquant\" href=\"http:\/\/pngquant.org\/\" target=\"_blank\">http:\/\/pngquant.org\/<\/a>. In my case,\u00a0I will download the binary for Windows.<\/p>\n<p style=\"text-align: justify;\">Once downloaded, we unzip the library at the place we want to install the tool. For example, in my case this place is \u00abC:\\ desarrollo\\ herramientas\\ pngquant\u00bb.<\/p>\n<p style=\"text-align: justify;\">When we unzip the library, we will have the content below:<\/p>\n<figure id=\"attachment_42\" aria-describedby=\"caption-attachment-42\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-42\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-1-300x129.png\" alt=\"Content of pngquant\" width=\"300\" height=\"129\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-1-300x129.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-1.png 384w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-42\" class=\"wp-caption-text\">Content of pngquant<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">As we can see, in addition to the library itself (pngquant.exe), provides a number of .bat scripts that will allow us to use the library quite quickly. Simply select the image you want to optimize and drag it onto these batch files, and automatically optimized image copy is created.<\/p>\n<p style=\"text-align: justify;\">Let&#8217;s see an example:<\/p>\n<ol>\n<li style=\"text-align: left;\">We take the following unoptimized PNG image. It is a file of 288 KB.\n<p><figure id=\"attachment_40\" aria-describedby=\"caption-attachment-40\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-40\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-300x169.png\" alt=\"Imagen original: 288 KB\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-300x169.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original.png 568w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-40\" class=\"wp-caption-text\">Original image: 288 KB<\/figcaption><\/figure><\/li>\n<li style=\"text-align: justify;\">We drag the image and drop it over script \u00ab<em>Drag PNG here to reduce palette automatically.bat<\/em>\u00bb of pngquant.\n<p><figure id=\"attachment_47\" aria-describedby=\"caption-attachment-47\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-47\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-2-300x115.png\" alt=\"Drag and drop over pngquant script\" width=\"300\" height=\"115\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-2-300x115.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-2.png 425w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-47\" class=\"wp-caption-text\">Drag and drop over pngquant script<\/figcaption><\/figure><\/li>\n<li style=\"text-align: justify;\">This automatically generates two optimized images, with suffix \u00ab-fs8\u00bb and \u00ab-or8\u00bb:\n<figure id=\"attachment_48\" aria-describedby=\"caption-attachment-48\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-fs8.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-48\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-fs8-300x169.png\" alt=\"Optimized image (fs8): 80 KB\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-fs8-300x169.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-fs8.png 568w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-48\" class=\"wp-caption-text\">Optimized image (fs8): 80 KB<\/figcaption><\/figure>\n<p><figure id=\"attachment_49\" aria-describedby=\"caption-attachment-49\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-or8.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-49\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-or8-300x169.png\" alt=\"Optimized image (or8): 75 KB\" width=\"300\" height=\"169\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-or8-300x169.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/monstegg_title-original-or8.png 568w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-49\" class=\"wp-caption-text\">Optimized image (or8): 75 KB<\/figcaption><\/figure><\/li>\n<li style=\"text-align: justify;\">As we can check, the size of the image file has been decreased more than 70% in both cases. Furthermore, I have to recognize that in a visual comparison I cannot distinguish changes.<\/li>\n<\/ol>\n<h4 style=\"text-align: justify;\">Installing pngquant<\/h4>\n<p style=\"text-align: justify;\">To can use <em>pngquant<\/em> from command line, we can install it on the system. For that, we simply add the path of <em>pngquant<\/em> installation to the system path (Windows):<\/p>\n<ol>\n<li style=\"text-align: justify;\">Access to \u00abControl Panel\u00bb &gt; \u00abSystem and security\u00bb &gt; \u00abSystem\u00bb<\/li>\n<li style=\"text-align: justify;\">Once here, select \u00abAdvanced system configuration\u00bb<\/li>\n<li style=\"text-align: justify;\">It will open \u00abSystem properties\u00bb. Select the tab \u00abAdvanced options\u00bb and next \u00abEnvironment variables\u00bb.\n<p><figure id=\"attachment_43\" aria-describedby=\"caption-attachment-43\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/Configuraci\u00f3n-avanzada-del-sistema.png\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-43 size-medium\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/Configuraci\u00f3n-avanzada-del-sistema-300x259.png\" alt=\"System advanced configuration\" width=\"300\" height=\"259\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/Configuraci\u00f3n-avanzada-del-sistema-300x259.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/Configuraci\u00f3n-avanzada-del-sistema.png 663w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-43\" class=\"wp-caption-text\">Access to window of environment variables for Windows<\/figcaption><\/figure><\/li>\n<li style=\"text-align: justify;\">In the window \u00abEnvironment variables\u00bb, select the variable \u00abpath\u00bb and click \u00abEdit&#8230;\u00bb button.<\/li>\n<li style=\"text-align: justify;\">In the new window we can edit the value for that variable.\u00a0To include <em>pngquant<\/em> in the system path, we must to add the character &#8216;;&#8217; followed by the path where we have unzip <em>pngquant<\/em>. In my case \u00abC:\\ desarrollo\\ herramientas\\ pngquant\u00bb:\n<p><figure id=\"attachment_50\" aria-describedby=\"caption-attachment-50\" style=\"width: 257px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/A\u00f1adir-pngquant-al-path.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-50\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/A\u00f1adir-pngquant-al-path-257x300.png\" alt=\"Add pngquant to system path\" width=\"257\" height=\"300\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/A\u00f1adir-pngquant-al-path-257x300.png 257w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/A\u00f1adir-pngquant-al-path.png 425w\" sizes=\"(max-width: 257px) 100vw, 257px\" \/><\/a><figcaption id=\"caption-attachment-50\" class=\"wp-caption-text\">Add pngquant to system path<\/figcaption><\/figure><\/li>\n<\/ol>\n<p style=\"text-align: justify;\">After instalation, we can use the library by typing \u00abpngquant\u00bb on command line:<\/p>\n<figure id=\"attachment_51\" aria-describedby=\"caption-attachment-51\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-4.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-51\" src=\"http:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-4-300x171.png\" alt=\"Using pngquant from command line\" width=\"300\" height=\"171\" srcset=\"https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-4-300x171.png 300w, https:\/\/www.pixnbgames.com\/blog\/wp-content\/uploads\/2014\/10\/pngquant-4.png 694w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-51\" class=\"wp-caption-text\">Using pngquant from command line<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h3>To know more<\/h3>\n<p style=\"text-align: justify;\">Of course, the use of <em>pngquant<\/em> does not end here. To go deeper in the use and the possibilities about this tools, you can check its website:\u00a0<a title=\"pngquant official website\" href=\"http:\/\/pngquant.org\/\" target=\"_blank\">http:\/\/pngquant.org\/<\/a><\/p>\n<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>When we develop software for mobile devices, we have to keep in mind that these devices have reduced specs if we compare its with traditional PCs. An aspect in which we have to put special attention is the program size, <a class=\"more-link\" href=\"https:\/\/www.pixnbgames.com\/blog\/tratamiento-imagenes\/decrease-size-of-png-images-with-pngquant\/\">Seguir leyendo <span class=\"screen-reader-text\">  Decrease size of PNG images with pngquant<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":41,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"language":[4],"_links":{"self":[{"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/posts\/55"}],"collection":[{"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":11,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions\/66"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/media\/41"}],"wp:attachment":[{"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/tags?post=55"},{"taxonomy":"language","embeddable":true,"href":"https:\/\/www.pixnbgames.com\/blog\/wp-json\/wp\/v2\/language?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}