{"id":3630,"date":"2017-08-23T07:29:23","date_gmt":"2017-08-23T07:29:23","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=3630"},"modified":"2017-08-23T08:58:46","modified_gmt":"2017-08-23T08:58:46","slug":"create-icons-splash-screen-images-automatically-ionic-framework-3","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/javascript\/ionic3\/create-icons-splash-screen-images-automatically-ionic-framework-3\/","title":{"rendered":"How to create icons and splash screen images automatically in Ionic framework 3"},"content":{"rendered":"<blockquote><p>\n  \u26a0\ufe0f In case you&#8217;re looking for how to create icons and splash screen images automatically in Ionic framework version 1, then you can check out <a href=\"http:\/\/www.nikola-breznjak.com\/blog\/javascript\/ionic\/create-icons-and-splash-screen-automatically-with-ionic-resources\/\">this post<\/a>. For more Ionic framework 3 posts check out the step by step info on <a href=\"http:\/\/www.nikola-breznjak.com\/blog\/javascript\/ionic3\/get-started-ionic-framework-3-mac-windows\/\">How to get started with Ionic framework 3 on Windows and Mac<\/a>.\n<\/p><\/blockquote>\n<h2>TL;DR<\/h2>\n<p>Just execute <code>ionic cordova resources<\/code> command in your Ionic 3 project root folder.<\/p>\n<h2>!TL;DR<\/h2>\n<p>The icon is an important part of your application because it represents your application&#8217;s brand, and it helps to identify quickly where the app is on your phone. In case you&#8217;re familiar with creating apps then you will remember that it is a tedious process to create a lot of different size images both for iOS and Android platforms.<\/p>\n<p>Also, the same goes for the so-called splash screen that shows up every time the application starts. Although having a splash screen is not mandatory, it certainly adds up to the feeling of a complete and professional application, which one would certainly want to convey with his application.<\/p>\n<p>Ionic helps tremendously with this by providing a single Ionic CLI command to generate all the needed icon and splash screen sizes for us automatically. Also, Ionic created <a href=\"http:\/\/code.ionicframework.com\/resources\/splash.psd\">Photoshop Splash Screen Template<\/a>, which you can download for free and use as a guideline for creating an icon. However, if you create you project by using <code>ionic start<\/code> command, as we have, then you&#8217;ll already have both the <code>icon.png<\/code> and <code>splash.png<\/code> files in the <code>resources<\/code> folder, and you can just edit them.<\/p>\n<p>For when you&#8217;re creating a branded product having a custom made icon is definitely a must. However, in this case, I&#8217;ll show you how to use one of the free services to search for a free icon which you can then use in your application (even if your application is a commercial application).<\/p>\n<p>I tend to use <a href=\"https:\/\/www.iconfinder.com?ref=Hitman666\">IconFinder<\/a> a lot, and here are the settings which you have to use to filter out the calculator images that are Free (PRICE) and can be used in commercial applications and that don&#8217;t even require a link back (LICENSE TYPE).<\/p>\n<p>Of course, you can also choose to buy an image if you happen to find one that you like. You can additionally search by format, size, and background. The filters should look like this (or use this <a href=\"https:\/\/www.iconfinder.com\/search\/?q=calculator&amp;license=2&amp;minimum=512&amp;maximum=512&amp;price=free&amp;ref=Hitman666\">prepared link which sets them automatically<\/a>):<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/IIi4opI.png\" alt=\"\" \/><\/p>\n<p>I&#8217;m going to use the last one in the first row. Simply click on it, and you should get to the download page that looks like this:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/BtvGIBC.png\" alt=\"\" \/><\/p>\n<p>To download it just click on the green &#8216;Download PNG&#8217; button.<\/p>\n<p>Now, in the <code>resources<\/code> folder find and open the <code>icon.png<\/code> file with an image editor of your choice. I&#8217;m going to use <a href=\"https:\/\/www.gimp.org\/\">Gimp<\/a> in this example as it&#8217;s free cross-platform image editor available for all the major operating systems (Linux, OS X, Windows). You should see something like this:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/lLbXt9G.png\" alt=\"\" \/><\/p>\n<p>Now we need to do a few steps:<\/p>\n<ul>\n<li>select the whole area (<code>Ctrl + a<\/code> or <code>Command + a<\/code>) and press the <code>DEL<\/code> button on your keyboard. This should leave you with a blank white canvas.<\/li>\n<li>drag the calculator icon on this white canvas and you should see something like this: <img decoding=\"async\" src=\"http:\/\/i.imgur.com\/00hlTzE.png\" alt=\"\" \/><\/li>\n<li>click on the scale tool<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/yFIhdhT.png\" alt=\"\" \/><\/li>\n<li>then click on the calculator image. You should get this popup:<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/O9UnBaW.png\" alt=\"\" \/><\/li>\n<li>change the values in the popup to <code>1024px<\/code> for both Width and Height and click the <code>Scale<\/code> button.<\/li>\n<li>click on the Alignment Tool, then click on the calculator image and then on the circled two buttons on the image below. This will align the calculator image horizontally and vertically<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/3uFV529.png\" alt=\"\" \/><\/li>\n<\/ul>\n<p>Now save the file by going to <code>File-&gt;Overwrite icon.png<\/code>:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/4C8mzLi.png\" alt=\"\" \/><\/p>\n<p>Repeat the process to create the splash screen image and name it (overwrite it as) <code>splash.png<\/code>. The image I came up with looks like this:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/a10DZi5.png\" alt=\"\" \/><\/p>\n<p>Now that you have both <strong>icon.png<\/strong> and <strong>splash.png<\/strong> images ready navigate with your Terminal\/Command prompt to the root folder of the application and run the following command:<\/p>\n<p><code>ionic cordova resources<\/code><\/p>\n<p>If at this point you get an error like this:<\/p>\n<p><code>[ERROR] No platforms have been added. Please run: ionic cordova platform add<\/code><\/p>\n<p>That means that you haven&#8217;t added any platforms yet to which Ionic should build. Since we&#8217;re going to build the app for both Apple Store and Android Play Store we&#8217;re going to use the following two commands:<\/p>\n<pre><code>ionic cordova platform add android\nionic cordova platform add ios\n<\/code><\/pre>\n<p>You should see an output similar to this:<\/p>\n<pre><code>ionic cordova platform add ios\n&gt; cordova platform add ios --save\n\u2714 Running command - done!\nUsing cordova-fetch for cordova-ios@~4.4.0\nAdding ios project...\nCreating Cordova project for the iOS platform:\n    Path: platforms\/ios\n    Package: io.ionic.starter\n    Name: MyApp\niOS project created with cordova-ios@4.4.0\nDiscovered plugin \"cordova-plugin-console\" in config.xml. Adding it to the project\nInstalling \"cordova-plugin-console\" for ios\nAdding cordova-plugin-console to package.json\nSaved plugin info for \"cordova-plugin-console\" to config.xml\nDiscovered plugin \"cordova-plugin-device\" in config.xml. Adding it to the project\nInstalling \"cordova-plugin-device\" for ios\nAdding cordova-plugin-device to package.json\nSaved plugin info for \"cordova-plugin-device\" to config.xml\nDiscovered plugin \"cordova-plugin-splashscreen\" in config.xml. Adding it to the project\nInstalling \"cordova-plugin-splashscreen\" for ios\nAdding cordova-plugin-splashscreen to package.json\nSaved plugin info for \"cordova-plugin-splashscreen\" to config.xml\nDiscovered plugin \"cordova-plugin-statusbar\" in config.xml. Adding it to the project\nInstalling \"cordova-plugin-statusbar\" for ios\nAdding cordova-plugin-statusbar to package.json\nSaved plugin info for \"cordova-plugin-statusbar\" to config.xml\nDiscovered plugin \"cordova-plugin-whitelist\" in config.xml. Adding it to the project\nInstalling \"cordova-plugin-whitelist\" for ios\nAdding cordova-plugin-whitelist to package.json\nSaved plugin info for \"cordova-plugin-whitelist\" to config.xml\nDiscovered plugin \"ionic-plugin-keyboard\" in config.xml. Adding it to the project\nInstalling \"ionic-plugin-keyboard\" for ios\nAdding ionic-plugin-keyboard to package.json\nSaved plugin info for \"ionic-plugin-keyboard\" to config.xml\n--save flag or autosave detected\nSaving ios@~4.4.0 into config.xml file ...\n\u2714 Copying default image resources into .\/resources\/ios - done!\n\n&gt; cordova platform add android --save\n\u2714 Running command - done!\nUsing cordova-fetch for cordova-android@~6.2.2\nAdding android project...\nCreating Cordova project for the Android platform:\n    Path: platforms\/android\n    Package: io.ionic.starter\n    Name: MyApp\n    Activity: MainActivity\n    Android target: android-25\nSubproject Path: CordovaLib\nAndroid project created with cordova-android@6.2.3\nInstalling \"cordova-plugin-console\" for android\nInstalling \"cordova-plugin-device\" for android\nInstalling \"cordova-plugin-splashscreen\" for android\nInstalling \"cordova-plugin-statusbar\" for android\nInstalling \"cordova-plugin-whitelist\" for android\n\n               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.\n\nInstalling \"ionic-plugin-keyboard\" for android\n--save flag or autosave detected\nSaving android@~6.2.3 into config.xml file ...\n\u2714 Copying default image resources into .\/resources\/android - done!\n<\/code><\/pre>\n<p>After this, you can safely run the <code>ionic cordova resources<\/code> command, and you should get the following output:<\/p>\n<pre><code>\u2714 Collecting resource configuration and source images - done!\n\u2714 Filtering out image resources that do not need regeneration - done!\n\u2714 Uploading source images to prepare for transformations - done!\n\u2714 Generating platform resources: 48 \/ 48 complete - done!\n\u2714 Modifying config.xml to add new image resources - done!\n<\/code><\/pre>\n<p>From the output, you can see that 48 images were created and hopefully now you realize how much time this saved. All the needed configuration regarding the icons and splash screens was generated by Ionic and placed in the <strong>config.xml<\/strong> file.<\/p>\n<p>It&#8217;s worth noting that you will not see the icon nor the splash screen when using the browser testing or Ionic View testing. Instead, you will only see these once you deploy them to the actual physical device or the emulator.<\/p>\n<blockquote><p>\n  \u26a0\ufe0f You can add an iOS platform if you&#8217;re developing on a Windows machine, and <code>ionic cordova resources<\/code> command will generate icons and splash screens for it. However, keep in mind that <strong>you will not be able to build the project for iOS on your Windows machine<\/strong>. Instead, you&#8217;ll need a Mac computer to do so.\n<\/p><\/blockquote>\n<blockquote class=\"twitter-tweet\" data-width=\"550\">\n<p lang=\"en\" dir=\"ltr\">How to create icons and splash screen images automatically in Ionic framework 3 <a href=\"https:\/\/twitter.com\/Ionicframework\">@ionicframework<\/a> <a href=\"https:\/\/t.co\/EKe3QDeo8E\">https:\/\/t.co\/EKe3QDeo8E<\/a><\/p>\n<p>&mdash; Nikola Bre\u017enjak (@HitmanHR) <a href=\"https:\/\/twitter.com\/HitmanHR\/status\/900258938100252672\">August 23, 2017<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u26a0\ufe0f In case you&#8217;re looking for how to create icons and splash screen images automatically in Ionic framework version 1, then you can check out this post. For&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3631,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-3630","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ionic3"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=3630"}],"version-history":[{"count":2,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3630\/revisions"}],"predecessor-version":[{"id":3633,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/3630\/revisions\/3633"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/3631"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=3630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=3630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=3630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}