{"id":556,"date":"2021-02-15T19:12:12","date_gmt":"2021-02-15T19:12:12","guid":{"rendered":"http:\/\/kevinmichaelcoy.com\/blog\/?p=556"},"modified":"2021-02-15T19:12:59","modified_gmt":"2021-02-15T19:12:59","slug":"convert-any-image-into-ascii-art-for-a-custom-spring-boot-banner","status":"publish","type":"post","link":"https:\/\/kevinmichaelcoy.com\/blog\/2021\/02\/15\/convert-any-image-into-ascii-art-for-a-custom-spring-boot-banner\/","title":{"rendered":"Convert any Image into ASCII Art for a Custom Spring Boot Banner"},"content":{"rendered":"\n<p>If you&#8217;d like to override the standard Spring Boot banner with something custom, then you&#8217;ve come to the right place. Find any image you want to convert to ASCII art. Then, download the following Git Hub project<\/p>\n\n\n<ul>\n<li><a href=\"https:\/\/github.com\/qeesung\/image2ascii\">https:\/\/github.com\/qeesung\/image2ascii\u00a0<\/a><\/li>\n<\/ul>\n\n\n<p>Now, you can run a script like the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/image2ascii -f ~\/Downloads\/trinity-neo-morpheus-2.jpg -g 57 -w 100 | tee banner.txt<\/code><\/pre>\n\n\n\n<p>You&#8217;ll see something like the following print out (in color):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1402\" height=\"801\" src=\"http:\/\/kevinmichaelcoy.com\/blog\/wp-content\/uploads\/2021\/02\/image.png\" alt=\"\" class=\"wp-image-557\"\/><figcaption>Trinity, Neo and Morpheus ASCII Art<\/figcaption><\/figure>\n\n\n\n<p>Now, you simply can put this file <code>banner.txt<\/code> into the appropriate folder in a Maven built Java project. If you put it into a common library with Autowiring, it will be available more readily to all of your dependent projects.<\/p>\n\n\n<ul>\n<li><code>src\/main\/resources\/banner.txt<\/code><\/li>\n<\/ul>\n\n\n<p>Now, you can just build and run and you&#8217;ll see this print out without any further configurations (following convention over configuration). If you really want to tweak the configurations you can use some of the following properties in the\u00a0<code>application.properties<\/code>\u00a0<\/p>\n\n\n\n<p><br><strong>spring.banner.charset<\/strong>: It configures banner encoding. Default is UTF-8<br><strong>spring.banner.location<\/strong>: It is banner file location. Default is classpath:banner.txt<br><strong>spring.banner.image.location<\/strong>: It configures banner image file location. Default is classpath:banner.gif. File can also be jpg, png.<br><strong>spring.banner.image.width<\/strong>: It configures width of the banner image in\u00a0<code>char<\/code>. Default is 76.<br><strong>spring.banner.image.height<\/strong>: It configures height of the banner image in\u00a0<code>char<\/code>. Default is based on image height.<br><strong>spring.banner.image.margin<\/strong>: It is left hand image margin in\u00a0<code>char<\/code>. Default is 2.<br><strong>spring.banner.image.invert<\/strong>: It configures if images should be inverted for dark terminal themes. Default is false.<br><strong>spring.main.banner-mode<\/strong>=off<\/p>\n\n\n\n<p>As, you can see you can use images as well. Also, if you were so inclined, you could even use variable substitution in your ASCII art for printing things out, such as the application name and version number.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;d like to override the standard Spring Boot banner with something custom, then you&#8217;ve come to the right place. Find any image you want to convert to ASCII art. Then, download the following Git Hub project https:\/\/github.com\/qeesung\/image2ascii\u00a0 Now, you can run a script like the following: You&#8217;ll see something&#8230;<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/kevinmichaelcoy.com\/blog\/2021\/02\/15\/convert-any-image-into-ascii-art-for-a-custom-spring-boot-banner\/\">Continue reading<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":2,"featured_media":557,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,3],"tags":[387,388,389,235],"_links":{"self":[{"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/posts\/556"}],"collection":[{"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/comments?post=556"}],"version-history":[{"count":1,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/posts\/556\/revisions"}],"predecessor-version":[{"id":558,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/posts\/556\/revisions\/558"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/media\/557"}],"wp:attachment":[{"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/media?parent=556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/categories?post=556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kevinmichaelcoy.com\/blog\/wp-json\/wp\/v2\/tags?post=556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}