├── bin └── image2springbanner.jar ├── .gitignore ├── README.md ├── pom.xml ├── src └── main │ └── java │ ├── Application.java │ └── ImageBanner.java └── LICENSE /bin/image2springbanner.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbornet/image2springbanner/HEAD/bin/image2springbanner.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # image2springbanner 2 | Small tool written in Java to convert images to spring-boot banner text resource. 3 | ## Credits 4 | Almost all the code comes from the Spring Boot [PR](https://github.com/spring-projects/spring-boot/pull/4647) by [Craig Burke](https://github.com/craigburke). 5 | When the PR is available in a Spring Boot release (probably 1.4), this project will no longer be of interest. 6 | ## Get it 7 | ### Pre-built jar 8 | Click [here](https://github.com/cbornet/image2springbanner/raw/master/bin/image2springbanner.jar) to download. 9 | ### From source 10 | Clone the project then in the project dir enter : 11 | ```shell 12 | mvn package 13 | ``` 14 | The jar will be in the ```target``` directory 15 | ## Usage 16 | ```shell 17 | usage: java -jar image2springbanner.jar [-c] [-d] [-M ] 18 | [-o ] [-r ] 19 | Create a Spring Boot banner from an image 20 | -c,--cie94 whether to use CIE94 algo (default is false) 21 | -d,--dark whether to invert image for a dark background. 22 | (default is false) 23 | -M,--max-width maximum width in characters of banner (default 24 | is 72) 25 | -o,--output output file path (default is ./banner.txt) 26 | -r,--aspect-ratio correction to makes sure height is correct to 27 | accomodate the fact that fonts are taller than 28 | they are wide. (default is 0.5) 29 | ``` 30 | Example : 31 | ``` 32 | java -jar image2springbanner.jar src/main/resources/banner.jpg -M140 -d -o src/main/resources/banner.txt 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | image2springbanner 4 | image2springbanner 5 | 0.0.1-SNAPSHOT 6 | image2springbanner 7 | 8 | 9 | 10 | commons-cli 11 | commons-cli 12 | 1.3 13 | 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-compiler-plugin 21 | 3.1 22 | 23 | 1.7 24 | 1.7 25 | 26 | 27 | 28 | org.apache.maven.plugins 29 | maven-shade-plugin 30 | 1.6 31 | 32 | true 33 | 34 | 35 | *:* 36 | 37 | META-INF/*.SF 38 | META-INF/*.DSA 39 | META-INF/*.RSA 40 | 41 | 42 | 43 | 44 | 45 | 46 | package 47 | 48 | shade 49 | 50 | 51 | 52 | 53 | 54 | Application 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/java/Application.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | import java.io.FileNotFoundException; 3 | import java.io.PrintWriter; 4 | import java.io.UnsupportedEncodingException; 5 | 6 | import org.apache.commons.cli.CommandLine; 7 | import org.apache.commons.cli.CommandLineParser; 8 | import org.apache.commons.cli.DefaultParser; 9 | import org.apache.commons.cli.HelpFormatter; 10 | import org.apache.commons.cli.Options; 11 | import org.apache.commons.cli.ParseException; 12 | 13 | public class Application { 14 | 15 | private static final String DEFAULT_MAX_WIDTH = "72"; 16 | private static final String DEFAULT_ASPECT_RATIO = "0.5"; 17 | 18 | public static void main(String[] args) throws ParseException, FileNotFoundException, UnsupportedEncodingException { 19 | Options options = new Options(); 20 | options.addOption("M", "max-width", true, "maximum width in characters of banner (default is 72)"); 21 | options.addOption("d", "dark", false, "whether to invert image for a dark background. (default is false)"); 22 | options.addOption("c", "cie94", false, "whether to use CIE94 algo (default is false)"); 23 | options.addOption("r", "aspect-ratio", true, "correction to makes sure height is correct to accomodate the fact that fonts are taller than they are wide. (default is 0.5)"); 24 | options.addOption("o", "output", true, "output file path (default is ./banner.txt)"); 25 | CommandLineParser parser = new DefaultParser(); 26 | CommandLine cmd = parser.parse( options, args); 27 | 28 | HelpFormatter formatter = new HelpFormatter(); 29 | if (cmd.getArgs().length == 0) { 30 | formatter.printHelp("java -jar image2springbanner.jar ", "Create a Spring Boot banner from an image", options, null, true); 31 | return; 32 | } 33 | 34 | ImageBanner banner = new ImageBanner(new File(cmd.getArgs()[0])); 35 | PrintWriter writer = new PrintWriter(cmd.getOptionValue("output", "banner.txt"), "UTF-8"); 36 | String bannerStr = banner.printBanner( 37 | Integer.parseInt(cmd.getOptionValue("M", DEFAULT_MAX_WIDTH)), 38 | Double.parseDouble(cmd.getOptionValue("r", DEFAULT_ASPECT_RATIO)), 39 | cmd.hasOption("d"), 40 | cmd.hasOption("c")); 41 | writer.println( bannerStr ); 42 | writer.close(); 43 | 44 | System.out.println(bannerStr 45 | .replace("${AnsiColor.DEFAULT}", "\u001B[39m") 46 | .replace("${AnsiColor.BLACK}", "\u001B[30m") 47 | .replace("${AnsiColor.RED}", "\u001B[31m") 48 | .replace("${AnsiColor.GREEN}", "\u001B[32m") 49 | .replace("${AnsiColor.YELLOW}", "\u001B[33m") 50 | .replace("${AnsiColor.BLUE}", "\u001B[34m") 51 | .replace("${AnsiColor.MAGENTA}", "\u001B[35m") 52 | .replace("${AnsiColor.CYAN}", "\u001B[36m") 53 | .replace("${AnsiColor.WHITE}", "\u001B[37m") 54 | .replace("${AnsiColor.BRIGHT_BLACK}", "\u001B[90m") 55 | .replace("${AnsiColor.BRIGHT_RED}", "\u001B[91m") 56 | .replace("${AnsiColor.BRIGHT_GREEN}", "\u001B[92m") 57 | .replace("${AnsiColor.BRIGHT_YELLOW}", "\u001B[93m") 58 | .replace("${AnsiColor.BRIGHT_BLUE}", "\u001B[94m") 59 | .replace("${AnsiColor.BRIGHT_MAGENTA}", "\u001B[95m") 60 | .replace("${AnsiColor.BRIGHT_CYAN}", "\u001B[96m") 61 | .replace("${AnsiColor.BRIGHT_WHITE}", "\u001B[97m") 62 | .replace("${AnsiBackground.BLACK}", "\u001B[40m") 63 | .replace("${AnsiBackground.DEFAULT}", "\u001B[49m") 64 | ); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/ImageBanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | 19 | import java.awt.Color; 20 | import java.awt.Image; 21 | import java.awt.color.ColorSpace; 22 | import java.awt.image.BufferedImage; 23 | import java.io.File; 24 | import java.io.FileInputStream; 25 | import java.util.HashMap; 26 | import java.util.Map; 27 | import java.util.Map.Entry; 28 | 29 | import javax.imageio.ImageIO; 30 | 31 | /** 32 | * Banner implementation that prints ASCII art generated from an image file 33 | * 34 | * @author Craig Burke 35 | * @author Christophe Bornet 36 | */ 37 | public class ImageBanner { 38 | 39 | private static final double RED_WEIGHT = 0.2126d; 40 | private static final double GREEN_WEIGHT = 0.7152d; 41 | private static final double BLUE_WEIGHT = 0.0722d; 42 | 43 | private File image; 44 | private Map colors = new HashMap(); 45 | 46 | public ImageBanner(File image) { 47 | if (image == null || !image.exists()) { 48 | throw new RuntimeException("Image not found !"); 49 | } 50 | this.image = image; 51 | colorsInit(); 52 | } 53 | 54 | private void colorsInit() { 55 | this.colors.put("BLACK", new Color(0, 0, 0)); 56 | this.colors.put("RED", new Color(170, 0, 0)); 57 | this.colors.put("GREEN", new Color(0, 170, 0)); 58 | this.colors.put("YELLOW", new Color(170, 85, 0)); 59 | this.colors.put("BLUE", new Color(0, 0, 170)); 60 | this.colors.put("MAGENTA", new Color(170, 0, 170)); 61 | this.colors.put("CYAN", new Color(0, 170, 170)); 62 | this.colors.put("WHITE", new Color(170, 170, 170)); 63 | 64 | this.colors.put("BRIGHT_BLACK", new Color(85, 85, 85)); 65 | this.colors.put("BRIGHT_RED", new Color(255, 85, 85)); 66 | this.colors.put("BRIGHT_GREEN", new Color(85, 255, 85)); 67 | this.colors.put("BRIGHT_YELLOW", new Color(255, 255, 85)); 68 | this.colors.put("BRIGHT_BLUE", new Color(85, 85, 255)); 69 | this.colors.put("BRIGHT_MAGENTA", new Color(255, 85, 255)); 70 | this.colors.put("BRIGHT_CYAN", new Color(85, 255, 255)); 71 | this.colors.put("BRIGHT_WHITE", new Color(255, 255, 255)); 72 | } 73 | 74 | public String printBanner(Integer maxWidth, Double aspectRatio, boolean invert, boolean cie94) { 75 | String headlessProperty = System.getProperty("java.awt.headless"); 76 | String banner = ""; 77 | try { 78 | System.setProperty("java.awt.headless", "true"); 79 | BufferedImage sourceImage = ImageIO.read(new FileInputStream(this.image)); 80 | BufferedImage resizedImage = resizeImage(sourceImage, maxWidth, aspectRatio); 81 | banner = imageToBanner(resizedImage, invert, cie94); 82 | } 83 | catch (Exception ex) { 84 | System.out.println("WARNING ! Image banner not printable: " + this.image + " (" + ex.getClass() 85 | + ": '" + ex.getMessage() + "')"); 86 | ex.printStackTrace(); 87 | } 88 | finally { 89 | if(headlessProperty != null) { 90 | System.setProperty("java.awt.headless", headlessProperty); 91 | } 92 | } 93 | return banner; 94 | } 95 | 96 | private String imageToBanner(BufferedImage image, boolean dark, boolean cie94) { 97 | StringBuilder banner = new StringBuilder(); 98 | 99 | for (int y = 0; y < image.getHeight(); y++) { 100 | if (dark) { 101 | banner.append("${AnsiBackground.BLACK}"); 102 | } 103 | else { 104 | banner.append("${AnsiBackground.DEFAULT}"); 105 | } 106 | for (int x = 0; x < image.getWidth(); x++) { 107 | Color color = new Color(image.getRGB(x, y), false); 108 | banner.append(getFormatString(color, dark, cie94)); 109 | } 110 | if (dark) { 111 | banner.append("${AnsiBackground.DEFAULT}"); 112 | } 113 | banner.append("${AnsiColor.DEFAULT}\n"); 114 | } 115 | 116 | return banner.toString(); 117 | } 118 | 119 | protected String getFormatString(Color color, boolean dark, boolean cie94) { 120 | String matchedColorName = null; 121 | Double minColorDistance = null; 122 | 123 | for (Entry colorOption : this.colors.entrySet()) { 124 | double distance; 125 | if (cie94 == true) { 126 | distance = getColorDistanceCIE94(color, colorOption.getValue()); 127 | } else { 128 | distance = getColorDistance(color, colorOption.getValue()); 129 | } 130 | 131 | if (minColorDistance == null || distance < minColorDistance) { 132 | minColorDistance = distance; 133 | matchedColorName = colorOption.getKey(); 134 | } 135 | } 136 | 137 | return "${AnsiColor." + matchedColorName + "}" + getAsciiCharacter(color, dark); 138 | } 139 | 140 | private static int getLuminance(Color color, boolean inverse) { 141 | double red = color.getRed(); 142 | double green = color.getGreen(); 143 | double blue = color.getBlue(); 144 | 145 | double luminance; 146 | 147 | if (inverse) { 148 | luminance = (RED_WEIGHT * (255.0d - red)) + (GREEN_WEIGHT * (255.0d - green)) 149 | + (BLUE_WEIGHT * (255.0d - blue)); 150 | } 151 | else { 152 | luminance = (RED_WEIGHT * red) + (GREEN_WEIGHT * green) 153 | + (BLUE_WEIGHT * blue); 154 | } 155 | 156 | return (int) Math.ceil((luminance / 255.0d) * 100); 157 | } 158 | 159 | private static char getAsciiCharacter(Color color, boolean dark) { 160 | double luminance = getLuminance(color, dark); 161 | 162 | if (luminance >= 90) { 163 | return ' '; 164 | } 165 | else if (luminance >= 80) { 166 | return '.'; 167 | } 168 | else if (luminance >= 70) { 169 | return '*'; 170 | } 171 | else if (luminance >= 60) { 172 | return ':'; 173 | } 174 | else if (luminance >= 50) { 175 | return 'o'; 176 | } 177 | else if (luminance >= 40) { 178 | return '&'; 179 | } 180 | else if (luminance >= 30) { 181 | return '8'; 182 | } 183 | else if (luminance >= 20) { 184 | return '#'; 185 | } 186 | else { 187 | return '@'; 188 | } 189 | } 190 | 191 | private static double getColorDistance(Color color1, Color color2) { 192 | double redDelta = (color1.getRed() - color2.getRed()) * RED_WEIGHT; 193 | double greenDelta = (color1.getGreen() - color2.getGreen()) * GREEN_WEIGHT; 194 | double blueDelta = (color1.getBlue() - color2.getBlue()) * BLUE_WEIGHT; 195 | 196 | return Math.pow(redDelta, 2.0d) + Math.pow(greenDelta, 2.0d) 197 | + Math.pow(blueDelta, 2.0d); 198 | } 199 | 200 | private static BufferedImage resizeImage(BufferedImage sourceImage, int maxWidth, 201 | double aspectRatio) { 202 | int width; 203 | double resizeRatio; 204 | if (sourceImage.getWidth() > maxWidth) { 205 | resizeRatio = (double) maxWidth / (double) sourceImage.getWidth(); 206 | width = maxWidth; 207 | } 208 | else { 209 | resizeRatio = 1.0d; 210 | width = sourceImage.getWidth(); 211 | } 212 | 213 | int height = (int) (Math.ceil(resizeRatio * aspectRatio 214 | * (double) sourceImage.getHeight())); 215 | Image image = sourceImage.getScaledInstance(width, height, Image.SCALE_DEFAULT); 216 | 217 | BufferedImage resizedImage = new BufferedImage(image.getWidth(null), 218 | image.getHeight(null), BufferedImage.TYPE_INT_RGB); 219 | 220 | resizedImage.getGraphics().drawImage(image, 0, 0, null); 221 | return resizedImage; 222 | } 223 | 224 | /** 225 | * Computes the CIE94 distance between two colors. 226 | * 227 | * Contributed by michael-simons 228 | * (original implementation https://github.com/michael-simons/dfx-mosaic/blob/public/src/main/java/de/dailyfratze/mosaic/images/CIE94ColorDistance.java) 229 | * 230 | * @param color1 the first color 231 | * @param color2 the second color 232 | * @return the distance between the colors 233 | */ 234 | private static double getColorDistanceCIE94(final Color color1, final Color color2) { 235 | // Convert to L*a*b* color space 236 | float[] lab1 = toLab(color1); 237 | float[] lab2 = toLab(color2); 238 | 239 | // Make it more readable 240 | double L1 = lab1[0]; 241 | double a1 = lab1[1]; 242 | double b1 = lab1[2]; 243 | double L2 = lab2[0]; 244 | double a2 = lab2[1]; 245 | double b2 = lab2[2]; 246 | 247 | // CIE94 coefficients for graphic arts 248 | double kL = 1; 249 | double K1 = 0.045; 250 | double K2 = 0.015; 251 | // Weighting factors 252 | double sl = 1.0; 253 | double kc = 1.0; 254 | double kh = 1.0; 255 | 256 | // See http://en.wikipedia.org/wiki/Color_difference#CIE94 257 | double c1 = Math.sqrt(a1 * a1 + b1 * b1); 258 | double deltaC = c1 - Math.sqrt(a2 * a2 + b2 * b2); 259 | double deltaA = a1 - a2; 260 | double deltaB = b1 - b2; 261 | double deltaH = Math.sqrt(Math.max(0.0, deltaA * deltaA + deltaB * deltaB - deltaC * deltaC)); 262 | 263 | return Math.sqrt(Math.max(0.0, Math.pow((L1 - L2) / (kL * sl), 2) + Math.pow(deltaC / (kc * (1 + K1 * c1)), 2) + Math.pow(deltaH / (kh * (1 + K2 * c1)), 2.0))); 264 | } 265 | 266 | /** 267 | * Returns the CIE L*a*b* values of this color. 268 | * 269 | * Implements the forward transformation described in 270 | * https://en.wikipedia.org/wiki/Lab_color_space 271 | * 272 | * @param color the color to convert 273 | * @return the xyz color components 274 | */ 275 | static float[] toLab(Color color) { 276 | float[] xyz = color.getColorComponents( 277 | ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), null); 278 | 279 | return xyzToLab(xyz); 280 | } 281 | 282 | static float[] xyzToLab(float[] colorvalue) { 283 | double l = f(colorvalue[1]); 284 | double L = 116.0 * l - 16.0; 285 | double a = 500.0 * (f(colorvalue[0]) - l); 286 | double b = 200.0 * (l - f(colorvalue[2])); 287 | return new float[]{(float) L, (float) a, (float) b}; 288 | } 289 | 290 | private static double f(double t) { 291 | if (t > 216.0 / 24389.0) { 292 | return Math.cbrt(t); 293 | } 294 | else { 295 | return (1.0 / 3.0) * Math.pow(29.0 / 6.0, 2) * t + (4.0 / 29.0); 296 | } 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------