{"id":22061,"date":"2014-06-25T03:04:44","date_gmt":"2014-06-25T01:04:44","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=22061"},"modified":"2014-06-25T03:07:50","modified_gmt":"2014-06-25T01:07:50","slug":"reducing-the-size-of-png-images","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2014\/06\/25\/reducing-the-size-of-png-images\/","title":{"rendered":"Reducing the size of PNG images"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I had an interesting problem today. \u00a0I was uploading a third-party theme to a WordPress hosted on the server that I don&#8217;t control and really don&#8217;t have much access to. \u00a0The server had a limitation of the upload size set to 10 MB. \u00a0Yeah, I know. \u00a0But not much I could do about that. \u00a0The theme that I was uploading was packed into an 11 MB ZIP file. \u00a0The theme itself was rather complicated (one of those commercially developed themes that are based on a framework and bring in a few plugins required for their functionality), so I couldn&#8217;t really remove anything from it.<\/p>\n<p>Upon a quick inspection, I realized that more than half of the ZIP weight is due to a multitude of PNG images. \u00a0 And while some image were small and legitimate &#8211; like, say, icons &#8211; quite a few others were packing lots of bytes for nothing &#8211; demos, sample images, and such. \u00a0Obviously, I wanted to reduce the size of these files significantly.<\/p>\n<p>My usual tool of choice for such tasks is usually <a href=\"http:\/\/www.imagemagick.org\/\">ImageMagick<\/a>. \u00a0To tell you the truth, I rarely work with PNG images. \u00a0JPEGs are a more frequent target for me. \u00a0So, I didn&#8217;t realize that <a href=\"http:\/\/www.imagemagick.org\/script\/command-line-options.php#quality\">ImageMagick handles <em>-quality<\/em> parameter differently for different image formats<\/a>\u00a0as fast as I&#8217;d like. \u00a0But even when I did, the results weren&#8217;t all that great. \u00a0In fact, the file sizes slightly grew in my tests.<\/p>\n<p>Looking for a different approach, I came across <a href=\"http:\/\/www.cyberciti.biz\/faq\/linux-unix-optimize-lossless-png-images-with-optipng-command\/\">this article<\/a> about a tool called <em>optipng<\/em>, which can be conveniently installed in Fedora via yum. \u00a0Unleashing this tool onto my PNG image collection showed me that whoever made the WordPress theme new what they were doing. \u00a0<em>opmipng<\/em> reported that all images are already optimized and there isn&#8217;t much to do.<\/p>\n<p>That&#8217;s when I found yet another tool to play with. \u00a0<a href=\"http:\/\/superuser.com\/questions\/246877\/bulk-convert-png-24-to-png-8-files-with-best-quality\">This discussion<\/a> at <del>StackOverflow<\/del> SuperUser suggests <em>pngquant<\/em>, which is also a breeze to install on Fedora with yum. \u00a0So finally, I did something like this:<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\n$ sudo yum install -y pngquant\r\n$ cd folder\/with\/images\r\n$ pngquant --force --ext .png --quality=0-75 *.png\r\n<\/pre>\n<p>That gave me exactly what I needed &#8211; a sufficient enough reduction in file sizes for the ZIP archive to fit into the upload limit set on the server.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I had an interesting problem today. \u00a0I was uploading a third-party theme to a WordPress hosted on the server that I don&#8217;t control and really don&#8217;t have much access to. \u00a0The server had a limitation of the upload size set to 10 MB. \u00a0Yeah, I know. \u00a0But not much I could do about that. \u00a0The &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2014\/06\/25\/reducing-the-size-of-png-images\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Reducing the size of PNG images<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,62,1334,60],"tags":[1258,246,1330],"keyring_services":[],"class_list":["post-22061","post","type-post","status-publish","format-standard","hentry","category-general","category-technology","category-web-work","category-wordpress","tag-images","tag-optimization","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":10729,"url":"https:\/\/mamchenkov.net\/wordpress\/2007\/06\/16\/daily-tweets\/","url_meta":{"origin":22061,"position":0},"title":"Daily tweets","author":"Leonid Mamchenkov","date":"June 16, 2007","format":false,"excerpt":"Today is Maxim's first graduation party. Toddler class, kindergarden. # Toddler graduation is about the cutest thing I saw in my life. Pictures are coming shortly. # TinyURL is down. All links give 500 Internal Server Error. What do we do now? # @atw26: I don't \"I'm online\" is an\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10080,"url":"https:\/\/mamchenkov.net\/wordpress\/2006\/04\/25\/flickr-saga-continues\/","url_meta":{"origin":22061,"position":1},"title":"Flickr saga continues","author":"Leonid Mamchenkov","date":"April 25, 2006","format":false,"excerpt":"I am moving forward with my Flickr saga. I ran out of bandwidth last month and was thinking that I'll use the time to edit and minimize some pictures, while I have to wait for more resources. That didn't happen. Instead, I realized that the last week of April has\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":15865,"url":"https:\/\/mamchenkov.net\/wordpress\/2011\/11\/08\/postr-gnome-flickr-uploader\/","url_meta":{"origin":22061,"position":2},"title":"Postr &#8211; Gnome Flickr Uploader","author":"Leonid Mamchenkov","date":"November 8, 2011","format":false,"excerpt":"Once again Flickr Web Uploader failed me. I had a bunch of photos to upload and it kept getting stuck on the first one, not uploading even that one. So, once again, I started looking around for a simple tool that would allow me to just upload a huge bunch\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2011\/11\/postr-500x366.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":12651,"url":"https:\/\/mamchenkov.net\/wordpress\/2010\/06\/29\/zip-vs-bzip2\/","url_meta":{"origin":22061,"position":3},"title":"Zip vs. Bzip2","author":"Leonid Mamchenkov","date":"June 29, 2010","format":false,"excerpt":"While investigating an unrelated issue on our backup server, I came across an interesting discussion about gzip vs. bzip2. I was surprised to read on how much slower bzip2 is. \u00a0I even tested it on our server. \u00a0And as expected, I saw the huge difference. [code lang=\"bash\"] $ du -sh\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10579,"url":"https:\/\/mamchenkov.net\/wordpress\/2006\/11\/13\/looking-for-a-new-wordpress-theme\/","url_meta":{"origin":22061,"position":4},"title":"Looking for a new WordPress theme","author":"Leonid Mamchenkov","date":"November 13, 2006","format":false,"excerpt":"I've been looking for a new WordPress theme for this blog, but I can't find anything that I like enough. Maybe I'm not ready yet, or maybe it's just that time of year. So, I thought, I'd ask for help from you guys. Here are a few things that I'm\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27266,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/01\/26\/html-canvas-tutorial\/","url_meta":{"origin":22061,"position":5},"title":"HTML Canvas Tutorial","author":"Leonid Mamchenkov","date":"January 26, 2017","format":false,"excerpt":"Skilled.co put together this HTML Canvas Tutorial, which covers the HTML 5 <canvas> functionality, that allows web developers to draw all sorts of graphics on the fly, using JavaScript. \u00a0The tutorial is available for download in PNG and PDF formats, as well as on the webpage, and it covers the\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/01\/canvas-500x228.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/22061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=22061"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/22061\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=22061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=22061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=22061"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=22061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}