{"id":2951,"date":"2014-12-07T08:26:24","date_gmt":"2014-12-07T14:26:24","guid":{"rendered":"http:\/\/benincosa.com\/blog\/?p=2951"},"modified":"2014-12-07T08:26:58","modified_gmt":"2014-12-07T14:26:58","slug":"ios-icon-size-generator","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=2951","title":{"rendered":"iOS icon size generator"},"content":{"rendered":"<p>One of the things you run into while developing iOS applications is that you need several different icon sizes for the various devices. \u00a0For an iOS 8 iPhone application, you need at least 4 different sizes: 58pt, 80pt, 120pt, and 180pt. \u00a0Not to mention the main icon size for the app store. \u00a0If you develop a Universal App for the iPad there&#8217;s even more!<\/p>\n<p>I&#8217;m sure there are tons of things people use to do this but I thought I&#8217;d throw my own solution in the mix as well.<\/p>\n<p>I use ImageMagick with a python script I wrote. \u00a0I like it because its quick and easy. \u00a0Plus, if you are developing in Ruby on Rails and need something like CarrierWave to upload images, you&#8217;ll already have ImageMagick installed.<\/p>\n<p>Here&#8217;s how it works:<\/p>\n<h2>1. \u00a0Install ImageMagick<\/h2>\n<p><span class=\"lang:default decode:true  crayon-inline \">brew install imagemagick<\/span><\/p>\n<h2>2. \u00a0Use my python script<\/h2>\n<pre class=\"lang:python decode:true \" title=\"makeicon.py\">#!\/usr\/bin\/env python\r\n# place the icon in the same directory as this script and run it. \r\n# e.g: .\/makeicons.py icon\\@1024.png\r\n\r\nfrom subprocess import call\r\nimport sys \r\n\r\nsizes = [29, 40, 60, 76 ]\r\n\r\nif len(sys.argv) &lt; 2:\r\n  print \"please enter a file name to process\"\r\n  exit()\r\n\r\nfor s in sizes:\r\n  for p in range(1,3):\r\n    ss = p * s \r\n    g = \"%dx%d\" % (ss, ss) \r\n    iconName = \"icon@%d.png\" % ss\r\n    print \"Making icon %s\" % iconName\r\n    call([\"convert\", sys.argv[1], \"-resize\", g, iconName])\r\n\r\ng = \"180x180\"\r\niconName = \"icon@180.png\"\r\nprint \"Making icon %s\" % iconName\r\ncall([\"convert\", sys.argv[1], \"-resize\", g, iconName])<\/pre>\n<h2>\u00a0Run the Python Script<\/h2>\n<p>With your original sized icon in the same directory as this script run the script. \u00a0Here&#8217;s my output example. \u00a0The file I put in the directory is called icon2@1024.png.<\/p>\n<pre class=\"striped:false nums:false nums-toggle:false lang:default decode:true \">$ .\/makeicons.py icon2\\@1024.png \r\nMaking icon icon@29.png\r\nMaking icon icon@58.png\r\nMaking icon icon@40.png\r\nMaking icon icon@80.png\r\nMaking icon icon@60.png\r\nMaking icon icon@120.png\r\nMaking icon icon@76.png\r\nMaking icon icon@152.png\r\nMaking icon icon@180.png<\/pre>\n<p>As you can see, it generated all the image sizes you would need for your asset images.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the things you run into while developing iOS applications is that you need several different icon sizes for the various devices. \u00a0For an iOS 8 iPhone application, you need at least 4 different sizes: 58pt, 80pt, 120pt, and 180pt. \u00a0Not to mention the main icon size for the app store. \u00a0If you develop&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[995,38,36],"tags":[589,588],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/2951"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2951"}],"version-history":[{"count":1,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/2951\/revisions"}],"predecessor-version":[{"id":2952,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/2951\/revisions\/2952"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}