{"componentChunkName":"component---src-templates-post-js","path":"/2011/07/07/batch-pngout-file-compressor/","result":{"data":{"site":{"siteMetadata":{"title":"Terry Butler","author":"Terry Butler"}},"markdownRemark":{"id":"3fb656e7-3794-5c43-9732-c890b6d59e2f","html":"<p>This is a batch file I wrote to handle the compression directories full of PNG files using Ken Silverman’s amazing <a href=\"http://advsys.net/ken/utils.htm\">PNGOUT</a> tool.</p>\n<p>Bear in mind that this isn’t exactly a replacement for <a href=\"http://www.ardfry.com/pngoutwin/\">PNGOUTWin</a> which supports asynchronous file compression taking advantage of multiple cores, this is merely a batch file that recursively navigates through a given directory and throws all PNGs one at a time at PNGOUT.</p>\n<p>Output example:</p>\n<p>Output for D:\\Images\\ for 88 files\n1252 kb before\n922 kb after\nsaving a total of 330 kb (26%)\nPress any key to continue . . .</p>\n<p>Instructions:</p>\n<ol>\n<li>\n<p>Download Ken Silverman’s command line PNGOUT tool (as provided in the link)</p>\n</li>\n<li>\n<p>Set the path for the pngo variable in the batch file</p>\n</li>\n<li>\n<p>Run the batch file simply like so</p>\n</li>\n</ol>\n<ul>\n<li><strong>pngout-batch</strong> “D:\\Images\\”</li>\n</ul>\n<ol start=\"9\">\n<li><strong>Optional</strong>: Create a shortcut to the batch file and place it in your SendTo folder for your user account for the sake of convenience</li>\n</ol>\n<ul>\n<li>\n<p>Windows XP</p>\n</li>\n<li>\n<p>C:\\Documents and Settings\\<em><strong><username></strong></em>\\SendTo</p>\n</li>\n<li>\n<p>Windows Vista / 7</p>\n</li>\n<li>\n<p>C:\\Users\\<em><strong><username></strong></em>\\AppData\\Roaming\\Microsoft\\Windows\\SendTo</p>\n</li>\n</ul>\n<p>Here is a preview of the batch file or you can download the batch file itself at the bottom of the post.</p>\n<p>::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: PNGOut Compressor Batch File v1.0\n::\n:: Author: Terry J. Butler\n:: Website: /\n:: Post URI: /2011/07/07/batch-pngout-file-compressor/\n:::READ ME::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Distribute this batch file as you'd like but I ask that you please leave this\n:: commented header section intact.\n:: If you want to modify this batch file, I ask that you give credit where credit\n:: is due.\n::\n:: Thanks to Ken Silverman for the fantastic PNGOut. Nothing compares to it.\n:: You'll need to download it from <a href=\"http://advsys.net/ken/utils.htm\">http://advsys.net/ken/utils.htm</a>, place it<br>\n:: somewhere convenient and change the path to it for the 'pngo' variable under the\n:: \"CONFIGURATION\" header\n::\n:: Thanks to the NT reference at SS64.com (<a href=\"http://ss64.com/nt/\">http://ss64.com/nt/</a>) for an incredible\n:: wealth of information that helped shape this batch file\n::\n:: Head to the link in the Post URI above for further details on how to use.\n:::CHANGE LOG:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n::\n:: v1.0\n:: - Initial Release\n::\n:::CONFIGURATION::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Set this path to the locaation of your pngout.exe file\nSET pngo=\"D:\\tools\\pngout.exe\"\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</p>\n<p>@echo off</p>\n<p>:: Setting EnabledDelayedExpansion will cause each variable to be expanded at execution\n:: time rather than at parse time. EnableDelayedExpansion is Disabled by default.\nsetLocal EnableDelayedExpansion</p>\n<p>:: set some arithmetic capable variables\nset /a value=0\nset /a sum=0\nset /a sumOriginal=0\nset /a count=0\nset /a diff=0\nset /a diffPercent=0</p>\n<p>pushd %1</p>\n<pre class=\"grvsc-container dark-visual-studio\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\">FOR /R %%G IN (\\*.png) DO (</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\techo Now Compressing %%G </span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\tset /a value=%%~zG</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\tset /a sum=!sum!+!value!\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\tset /a count+=1</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\t%pngo% &quot;%%G&quot;</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a sumOriginal=sum/1024</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a value=0</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a sum=0</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">FOR /R %%G IN (\\*.png) DO (</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\tset /a value=%%~zG</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">\tset /a sum=!sum!+!value!\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a sum=sum/1024\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a diff=!sumOriginal!-!sum!\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">set /a diffPercent=(100\\*(!sumOriginal!-!sum!))/!sumOriginal!;\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">@echo Output for %CD% for %count% files</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">@echo !sumOriginal! kb before</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">@echo !sum! kb after\t</span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\">@echo saving a total of !diff! kb (!diffPercent!%% decrease)</span></span></code></pre>\n<p>popd</p>\n<p>:: Unset variables\nSET _value=\nSET _sum=\nSET _sumOriginal=\nSET _count=\nSET _diff=\nSET _diffPercent=</p>\n<p>pause</p>\n<p><a href=\"/downloads/pngout-batch/pngout-batch.bat\">Download pngout-batch.bat</a></p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    position: relative;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n    line-height: 1.4;\n  }\n  \n  .grvsc-code {\n    display: table;\n  }\n  \n  .grvsc-line {\n    display: table-row;\n    box-sizing: border-box;\n    width: 100%;\n    position: relative;\n  }\n  \n  .grvsc-line > * {\n    position: relative;\n  }\n  \n  .grvsc-gutter-pad {\n    display: table-cell;\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  .grvsc-gutter {\n    display: table-cell;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter::before {\n    content: attr(data-content);\n  }\n  \n  .grvsc-source {\n    display: table-cell;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-source:empty::after {\n    content: ' ';\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter + .grvsc-source {\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  /* Line transformer styles */\n  \n  .grvsc-has-line-highlighting > .grvsc-code > .grvsc-line::before {\n    content: ' ';\n    position: absolute;\n    width: 100%;\n  }\n  \n  .grvsc-line-diff-add::before {\n    background-color: var(--grvsc-line-diff-add-background-color, rgba(0, 255, 60, 0.2));\n  }\n  \n  .grvsc-line-diff-del::before {\n    background-color: var(--grvsc-line-diff-del-background-color, rgba(255, 0, 20, 0.2));\n  }\n  \n  .grvsc-line-number {\n    padding: 0 2px;\n    text-align: right;\n    opacity: 0.7;\n  }\n  \n  .dark-visual-studio {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-visual-studio .grvsc-line-highlighted::before {\n    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));\n  }\n</style>","frontmatter":{"title":"Batch PNGOut File Compressor","date":"July 07, 2011","categories":["Uncategorized"],"tags":null,"featuredImage":null}}},"pageContext":{"slug":"/2011/07/07/batch-pngout-file-compressor/","previous":{"fields":{"slug":"/2011/05/30/mod-monday-92/","sourceName":"posts"},"excerpt":"This is “Einstein-2c8” by Einstein (Poul Peder Hestbek). Download MP3 Download MOD","frontmatter":{"title":"MOD Monday #92","date":"May 30, 2011","categories":["MOD Monday"],"tags":["Einstein","Poul Peder Hestbek"],"featuredImage":null}},"next":{"fields":{"slug":"/2011/08/09/worth-see-ray-tracing-videos/","sourceName":"posts"},"excerpt":"Animated Sparse Voxel Octrees: In-depth pt1/3 Animated Sparse Voxel Octrees: In-depth pt2/3 Animated Sparse Voxel Octrees: In-depth pt3/3 Interactive Indirect Illumination Using Voxel Cone Tracing","frontmatter":{"title":"Worth-See Ray Tracing Videos","date":"August 9, 2011","categories":["Uncategorized"],"tags":["CyrilCrassin","QuadTree","Radulphi","Ray Tracing","Sparse Voxel Octree","SVC","Videos","YouTube"],"featuredImage":null}}}},"staticQueryHashes":["63159454"]}