├── manifest.mf ├── .gitignore ├── nbproject ├── genfiles.properties ├── project.xml ├── project.properties └── build-impl.xml ├── README.md ├── LICENSE ├── consoleImageViewer.man └── src └── org └── judovana └── linux └── ConsoleImageViewer.java /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | /nbproject/private/ 14 | /build/ 15 | /dist/ -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=54dc2b26 2 | build.xml.script.CRC32=1cc33d51 3 | build.xml.stylesheet.CRC32=8064a381@1.75.2.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=54dc2b26 7 | nbproject/build-impl.xml.script.CRC32=6637a287 8 | nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 9 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | ConsoleImageViewer 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ConsoleImageViewer 2 | 3 | 4 | Už jste někdy hledali na headless (čili bez X, čili bez grafického rozhraní, bez monitoru, bez vnc, …) ikonku? Ne? To se máte:). Já ano. A na potvoru tam nebyly žádné devel balíčky a vlastně jsem ani neměl roota, ale náhodou tam byla java, a to dokonce i s javac. 5 | 6 | Výsledný prográmek je jedna jediná třída (dokonce i po kompilaci), jejíž logika, cca 100 řádků, je mnohem jednodušší, než samotné rozumění parametrům. Za výsledky nechť promluví: 7 | 8 | dnf install console-image-viewer 9 | 10 | a 11 | 12 | consoleImageViewer -names -best /usr/share/app-info/icons/fedora/128x128/* (případně s | less -R ) 13 | 14 | ![preview](https://mojefedora.cz/wp-content/uploads/2016/05/console-image-587x1024.png) 15 | 16 | from https://mojefedora.cz/poberky-z-fedorky/ 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /consoleImageViewer.man: -------------------------------------------------------------------------------- 1 | .TH consoleImageViewer 1 "December 04, 2015" "version 1.2" "USER COMMANDS" 2 | .SH NAME 3 | consoleImageViewer \- highly scale-able, high quality, image viewer for ANSI terminals 4 | .SH SYNOPSIS 5 | .B consoleImageViewer 6 | [\-h][\--help][\-best][\-fg][\-bg][\-nochar][\-names][\-ratio][\-rect][\-negChar][\-negColor][\-wX][\-hX] image-name(s) 7 | .PP 8 | Number of hyphens nor case meter for switches. 9 | .SH DESCRIPTION 10 | Not exactly photo-viewer, but when in terminal, and need quick preview of (small) image(s) then it is best of its kind 11 | .PP 12 | It is strongly recommended to 'export COLUMNS LINES' to adapt correctly to your terminal 13 | .SH OPTIONS 14 | .TP 15 | \-h/--help 16 | print help and exits 17 | .TP 18 | \-best 19 | overwrite everything and set best settngs 20 | .TP 21 | \-bestnchar 22 | same but sets nochar to true 23 | .TP 24 | \-fg 25 | use linux ansi escape color for character 26 | .TP 27 | \-bg 28 | use linux ansi escape color for background 29 | .TP 30 | \-nochar 31 | disable shadowing by characters 32 | .TP 33 | \-names 34 | prints out image name before drawing it 35 | .TP 36 | \-ratio 37 | forece to keep image ratio 38 | .TP 39 | \-rect 40 | will force rendering assuming that console char is not square, but rectangle of 2w~=h 41 | .TP 42 | \-negChar 43 | invert chars 44 | .TP 45 | \-negColor 46 | invert colors 47 | .TP 48 | \-wX 49 | force width to width X ignoring exported COLUMNS 50 | .TP 51 | \-hX 52 | force height to height X ignoring exported LINES 53 | 54 | .SH EXAMPLES 55 | .TP 56 | No switch is considered as -best 57 | .B consoleImageViewer 58 | 59 | .TP 60 | same as 61 | .B consoleImageViewer 62 | -best 63 | .PP 64 | .TP 65 | Pretty good black and white (or any terminal default view) 66 | .B consoleImageViewer 67 | \-ratio -rect -negChar 68 | .TP 69 | Overriding default or COLUMNS/ROWS by seize of 128 (-noChar is ignored because -best is used) 70 | .B consoleImageViewer 71 | \-best -noChar -w128 -h128 72 | .PP 73 | .SH EXIT STATUS 74 | consoleImageViewer returns zero unless itcrashes 75 | .SH AUTHOR 76 | Jiri Vanek (judovana (at) email.cz) 77 | .SH SEE ALSO 78 | dispaly(1) 79 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=ConsoleImageViewer 7 | application.vendor=jvanek 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.test.classpath=\ 23 | ${run.test.classpath} 24 | # Files in build.classes.dir which should be excluded from distribution jar 25 | dist.archive.excludes= 26 | # This directory is removed when the project is cleaned: 27 | dist.dir=dist 28 | dist.jar=${dist.dir}/ConsoleImageViewer.jar 29 | dist.javadoc.dir=${dist.dir}/javadoc 30 | endorsed.classpath= 31 | excludes= 32 | includes=** 33 | jar.compress=false 34 | javac.classpath= 35 | # Space-separated list of extra javac options 36 | javac.compilerargs= 37 | javac.deprecation=false 38 | javac.processorpath=\ 39 | ${javac.classpath} 40 | javac.source=1.6 41 | javac.target=1.6 42 | javac.test.classpath=\ 43 | ${javac.classpath}:\ 44 | ${build.classes.dir} 45 | javac.test.processorpath=\ 46 | ${javac.test.classpath} 47 | javadoc.additionalparam= 48 | javadoc.author=false 49 | javadoc.encoding=${source.encoding} 50 | javadoc.noindex=false 51 | javadoc.nonavbar=false 52 | javadoc.notree=false 53 | javadoc.private=false 54 | javadoc.splitindex=true 55 | javadoc.use=true 56 | javadoc.version=false 57 | javadoc.windowtitle= 58 | main.class=org.judovana.linux.ConsoleImageViewer 59 | manifest.file=manifest.mf 60 | meta.inf.dir=${src.dir}/META-INF 61 | mkdist.disabled=false 62 | platform.active=default_platform 63 | run.classpath=\ 64 | ${javac.classpath}:\ 65 | ${build.classes.dir} 66 | # Space-separated list of JVM arguments used when running the project. 67 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 68 | # To set system properties for unit tests define test-sys-prop.name=value: 69 | run.jvmargs= 70 | run.test.classpath=\ 71 | ${javac.test.classpath}:\ 72 | ${build.test.classes.dir} 73 | source.encoding=UTF-8 74 | src.dir=src 75 | test.src.dir=test 76 | -------------------------------------------------------------------------------- /src/org/judovana/linux/ConsoleImageViewer.java: -------------------------------------------------------------------------------- 1 | package org.judovana.linux; 2 | 3 | import javax.imageio.ImageIO; 4 | import java.awt.*; 5 | import java.awt.image.BufferedImage; 6 | import java.io.File; 7 | import java.io.IOException; 8 | 9 | 10 | /* 11 | Based on https://gist.github.com/shmert/3859200 with follwoing copiright. 12 | However modified to much. 13 | Intetnionaly one static class. 14 | 15 | Modifications by Jiri Vanek, coloring, stretching, applicalization 16 | Modifications by Sam Barnum, 360Works 2012 17 | original Copyright (c) 2011 Aravind Rao 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 20 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to 21 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 22 | * to whom the Software is furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 27 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 29 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | public final class ConsoleImageViewer { 32 | 33 | private static boolean ratio; 34 | private static boolean rect; 35 | private static boolean bg; 36 | private static boolean fg; 37 | private static boolean noChar; 38 | private static boolean negChar; 39 | private static boolean negCol; 40 | private static int w; 41 | private static int h; 42 | private static boolean names; 43 | 44 | public static void printHelp() { 45 | System.out.println("Utility to render images to console"); 46 | System.out.println("to work best use 'export COLUMNS LINES' otherwise standard terminal of 80x25 will be used "); 47 | System.out.println("-h --help - print help and exits"); 48 | System.out.println("Necessary parameter is any follwoing optional switches (1-n FILES supported):"); 49 | System.out.println("-best - overwrite everything and set best settngs"); 50 | System.out.println("-bestnchar - same but sets nochar to true"); 51 | System.out.println("-fg - use linux ansi escape color for character"); 52 | System.out.println("-bg - use linux ansi escape color for background"); 53 | System.out.println("-nochar - disable shadowing by characters"); 54 | System.out.println("-names - prints out image name before drawing it"); 55 | System.out.println("-ratio - forece to keep image ratio"); 56 | System.out.println("-rect - will force rendering assuming that console char is not square, but rectangle of 2w~=h"); 57 | System.out.println("-negChar - invert chars"); 58 | System.out.println("-negColor - invert colors"); 59 | System.out.println("-wX - force width"); 60 | System.out.println("-hX - force height"); 61 | } 62 | 63 | private static boolean haveArg(String[] args) { 64 | int items = 0; 65 | for (String arg : args) { 66 | if (arg.startsWith("-")) { 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | private static String[] getFiles(String[] args) { 74 | int items = 0; 75 | for (String arg : args) { 76 | if (!arg.startsWith("-")) { 77 | items++; 78 | } 79 | } 80 | if (items == 0) { 81 | throw new RuntimeException("No file found!"); 82 | } 83 | String[] r = new String[items]; 84 | int counter = 0; 85 | for (String arg : args) { 86 | if (!arg.startsWith("-")) { 87 | r[counter] = arg; 88 | counter++; 89 | } 90 | } 91 | return r; 92 | } 93 | 94 | public static boolean haveParam(String param, String[] args) { 95 | return haveParam(param, args, false); 96 | 97 | } 98 | 99 | private static boolean haveParam(String param, String[] args, boolean defaults) { 100 | for (String arg : args) { 101 | if (arg.startsWith("-")) { 102 | String s = arg.replaceAll("-", ""); 103 | if (s.equalsIgnoreCase(param)) { 104 | return true; 105 | } 106 | } 107 | } 108 | return defaults; 109 | } 110 | 111 | private static int getParam(String w, String[] args, int i) { 112 | for (String arg : args) { 113 | if (arg.startsWith("-")) { 114 | String s = arg.replaceAll("-", ""); 115 | if (s.startsWith(w)) { 116 | return new Integer(s.substring(1)); 117 | } 118 | } 119 | } 120 | return i; 121 | } 122 | 123 | public static void setParams(String[] args) { 124 | ratio = haveParam("ratio", args); 125 | rect = haveParam("rect", args); 126 | bg = haveParam("bg", args); 127 | fg = haveParam("fg", args); 128 | noChar = haveParam("nochar", args); 129 | negChar = haveParam("negChar", args); 130 | negCol = haveParam("negColor", args); 131 | if (haveParam("best", args) || haveParam("bestnchar", args)) { 132 | ratio = true; 133 | rect = true; 134 | bg = true; 135 | fg = false; 136 | if (haveParam("best", args)) { 137 | noChar = false; 138 | } 139 | if (haveParam("bestnchar", args)) { 140 | noChar = true; 141 | } 142 | negChar = true; 143 | negCol = false; 144 | } 145 | w = getParam("w", args, 80); 146 | h = getParam("h", args, 25); 147 | names = haveParam("names", args); 148 | } 149 | 150 | public static void doJob(BufferedImage image) { 151 | //use exported! export COLUMNS LINES to find size 152 | //force ratio? think about char in consoel is not square, but rectangle 2w=h 153 | String systemWidth = System.getenv("COLUMNS"); 154 | String systemHeight = System.getenv("LINES"); 155 | if (systemWidth != null && w == 80) { 156 | w = Integer.valueOf(systemWidth); 157 | } else { 158 | if (w == 80) { 159 | System.err.println("Warning COLUMNS varibale not exported nor -w specified! Standart " + w + " used"); 160 | } 161 | } 162 | if (systemHeight != null && h == 25) { 163 | h = Integer.valueOf(systemHeight); 164 | } else { 165 | if (h == 25) { 166 | System.err.println("Warning LINES varibale not exported nor -h specified! Standart " + h + " used"); 167 | } 168 | } 169 | String ascii = doAll(rect, image, w, h, ratio, fg, bg, noChar, negChar, negCol); 170 | System.out.print(ascii); 171 | System.out.println(); 172 | } 173 | 174 | boolean negative; 175 | 176 | public static String convert(final BufferedImage image, boolean fg, boolean bg, boolean drawChar, boolean negChar, boolean negColor) { 177 | int imgSize = (image.getWidth() + 1) * image.getHeight(); 178 | int colorSize = 0; 179 | if (fg) { 180 | colorSize += 18; 181 | } 182 | if (bg) { 183 | colorSize += 18; 184 | } 185 | StringBuilder sb = new StringBuilder(imgSize + imgSize * colorSize); 186 | for (int y = 0; y < image.getHeight(); y++) { 187 | reset(fg, sb, bg); 188 | if (sb.length() != 0) { 189 | sb.append("\n"); 190 | } 191 | for (int x = 0; x < image.getWidth(); x++) { 192 | Color pixelColor = new Color(image.getRGB(x, y)); 193 | if (fg || bg) { 194 | int ansi = colorToAnsiColor(pixelColor, negColor); 195 | if (fg) { 196 | sb.append(ansiColorToEscapedString(ansi, true)); 197 | } 198 | if (bg) { 199 | sb.append(ansiColorToEscapedString(ansi, false)); 200 | } 201 | } 202 | if (drawChar) { 203 | double gValue = (double) pixelColor.getRed() * 0.2989 + (double) pixelColor.getBlue() * 0.5870 + (double) pixelColor.getGreen() * 0.1140; 204 | final char s = negChar ? returnStrNeg(gValue) : returnStrPos(gValue); 205 | sb.append(s); 206 | } else { 207 | sb.append(" "); //nocahr, just color 208 | } 209 | //best is with char, and bg only 210 | } 211 | } 212 | reset(fg, sb, bg); 213 | return sb.toString(); 214 | } 215 | 216 | private static void reset(boolean fg1, StringBuilder sb, boolean bg1) { 217 | if (fg1) { 218 | sb.append(ansiColorToEscapedString(15, true)); 219 | } 220 | if (bg1) { 221 | sb.append(ansiColorToEscapedString(0, false)); 222 | } 223 | } 224 | 225 | private static String ansiColorToEscapedString(int ansi, boolean fg) { 226 | if (fg) { 227 | return "\033[38;5;" + ansi + "m"; //fg 228 | } else { 229 | return "\033[48;5;" + ansi + "m"; //bg 230 | } 231 | 232 | } 233 | 234 | /** 235 | * r=3; g=0; b=2; let number=16+36*r+6*g+b; COLOR='\033[38;5;'$number'm' ; 236 | * NC='\033[0m' ; echo -e "I ${COLOR}love${NC} Stack" 237 | * http://stackoverflow.com/questions/15682537/ansi-color-specific-rgb-sequence-bash 238 | * 239 | * @param pixelColor 240 | * @return 241 | */ 242 | private static int colorToAnsiColor(Color pixelColor, boolean negative) { 243 | int n = 0; 244 | if (negative) { 245 | n = 255; 246 | } 247 | int ansiR = Math.abs(n - pixelColor.getRed()) / 50; 248 | int ansiG = Math.abs(n - pixelColor.getGreen()) / 50; 249 | int ansiB = Math.abs(n - pixelColor.getBlue()) / 50; 250 | int ansi = 16 + 36 * ansiR + 6 * ansiG + ansiB; 251 | return ansi; 252 | } 253 | 254 | /** 255 | * Create a new string and assign to it a string based on the grayscale 256 | * value. If the grayscale value is very high, the pixel is very bright and 257 | * assign characters such as . and , that do not appear very dark. If the 258 | * grayscale value is very lowm the pixel is very dark, assign characters 259 | * such as # and @ which appear very dark. 260 | * 261 | * @param g grayscale 262 | * @return char 263 | */ 264 | private static char returnStrPos(double g)//takes the grayscale value as parameter 265 | { 266 | final char str; 267 | 268 | if (g >= 230.0) { 269 | str = ' '; 270 | } else if (g >= 200.0) { 271 | str = '.'; 272 | } else if (g >= 180.0) { 273 | str = '*'; 274 | } else if (g >= 160.0) { 275 | str = ':'; 276 | } else if (g >= 130.0) { 277 | str = 'o'; 278 | } else if (g >= 100.0) { 279 | str = '&'; 280 | } else if (g >= 70.0) { 281 | str = '8'; 282 | } else if (g >= 50.0) { 283 | str = '#'; 284 | } else { 285 | str = '@'; 286 | } 287 | return str; // return the character 288 | 289 | } 290 | 291 | /** 292 | * Same method as above, except it reverses the darkness of the pixel. A 293 | * dark pixel is given a light character and vice versa. 294 | * 295 | * @param g grayscale 296 | * @return char 297 | */ 298 | private static char returnStrNeg(double g) { 299 | final char str; 300 | 301 | if (g >= 230.0) { 302 | str = '@'; 303 | } else if (g >= 200.0) { 304 | str = '#'; 305 | } else if (g >= 180.0) { 306 | str = '8'; 307 | } else if (g >= 160.0) { 308 | str = '&'; 309 | } else if (g >= 130.0) { 310 | str = 'o'; 311 | } else if (g >= 100.0) { 312 | str = ':'; 313 | } else if (g >= 70.0) { 314 | str = '*'; 315 | } else if (g >= 50.0) { 316 | str = '.'; 317 | } else { 318 | str = ' '; 319 | } 320 | return str; 321 | 322 | } 323 | 324 | private static BufferedImage resize(BufferedImage img, int newW, int newH, boolean ratio) { 325 | if (ratio) { 326 | double wR = (double) newW / (double) img.getWidth(); 327 | double hR = (double) newH / (double) img.getHeight(); 328 | if (wR > hR) { 329 | newW = (int) (hR * (double) img.getWidth()); 330 | } else { 331 | newH = (int) (wR * (double) img.getHeight()); 332 | } 333 | } 334 | Image tmp = img.getScaledInstance(newW, newH, Image.SCALE_SMOOTH); 335 | BufferedImage dimg = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_ARGB); 336 | Graphics2D g2d = dimg.createGraphics(); 337 | g2d.drawImage(tmp, 0, 0, null); 338 | g2d.dispose(); 339 | 340 | return dimg; 341 | } 342 | 343 | public static void main(String[] args) throws IOException { 344 | if (args.length > 0) { 345 | tui(args); 346 | } else { 347 | printHelp(); 348 | } 349 | } 350 | 351 | private static void tui(String[] args) throws IOException { 352 | if (haveParam("help", args) || haveParam("h", args)) { 353 | printHelp(); 354 | System.exit(0); 355 | } 356 | if (!haveArg(args)) { 357 | String[] oldArgs = args; 358 | args = new String[oldArgs.length + 1]; 359 | args[0] = "-best"; 360 | for (int i = 0; i < oldArgs.length; i++) { 361 | String arg = oldArgs[i]; 362 | args[i + 1] = arg; 363 | } 364 | 365 | } 366 | setParams(args); 367 | String[] s = getFiles(args); 368 | for (String s1 : s) { 369 | try { 370 | BufferedImage image = ImageIO.read(new File(s1)); 371 | if (image == null) { 372 | throw new IllegalArgumentException(s1 + " is not a valid image."); 373 | } 374 | if (names) { 375 | System.out.println(s1); 376 | } 377 | doJob(image); 378 | } catch (Exception ex) { 379 | ex.printStackTrace(); 380 | } 381 | } 382 | 383 | } 384 | 385 | private static String doAll(boolean rect, BufferedImage image, int w, int h, boolean ratio, boolean fg, boolean bg, boolean noChar, boolean negChar, boolean negCol) { 386 | if (rect) { 387 | //HxW of terminal char 388 | //78x56 389 | //39*28 390 | double rectMod = 56d / 78d; 391 | //surprisingly still bad 392 | rectMod = 56d / (1.7d * 78d); 393 | int nh = (int) ((double) image.getHeight() * rectMod); 394 | image = resize(image, image.getWidth(), nh, false); 395 | 396 | } 397 | image = resize(image, w, h, ratio); 398 | final String ascii = convert(image, fg, bg, !noChar, negChar, negCol); 399 | return ascii; 400 | } 401 | 402 | public static int getW() { 403 | return w; 404 | } 405 | 406 | public static int getH() { 407 | return h; 408 | } 409 | 410 | } 411 | -------------------------------------------------------------------------------- /nbproject/build-impl.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | Must set src.dir 227 | Must set test.src.dir 228 | Must set build.dir 229 | Must set dist.dir 230 | Must set build.classes.dir 231 | Must set dist.javadoc.dir 232 | Must set build.test.classes.dir 233 | Must set build.test.results.dir 234 | Must set build.classes.excludes 235 | Must set dist.jar 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | Must set javac.includes 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | No tests executed. 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | Must set JVM to use for profiling in profiler.info.jvm 716 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent 717 | 718 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | Must select some files in the IDE or set javac.includes 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | To run this application from the command line without Ant, try: 995 | 996 | java -jar "${dist.jar.resolved}" 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | Must select one file in the IDE or set run.class 1044 | 1045 | 1046 | 1047 | Must select one file in the IDE or set run.class 1048 | 1049 | 1050 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | Must select one file in the IDE or set debug.class 1075 | 1076 | 1077 | 1078 | 1079 | Must select one file in the IDE or set debug.class 1080 | 1081 | 1082 | 1083 | 1084 | Must set fix.includes 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1096 | 1099 | 1100 | This target only works when run from inside the NetBeans IDE. 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | Must select one file in the IDE or set profile.class 1110 | This target only works when run from inside the NetBeans IDE. 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | This target only works when run from inside the NetBeans IDE. 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | This target only works when run from inside the NetBeans IDE. 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | Must select one file in the IDE or set run.class 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | Must select some files in the IDE or set test.includes 1177 | 1178 | 1179 | 1180 | 1181 | Must select one file in the IDE or set run.class 1182 | 1183 | 1184 | 1185 | 1186 | Must select one file in the IDE or set applet.url 1187 | 1188 | 1189 | 1190 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | Must select some files in the IDE or set javac.includes 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | Some tests failed; see details above. 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | Must select some files in the IDE or set test.includes 1299 | 1300 | 1301 | 1302 | Some tests failed; see details above. 1303 | 1304 | 1305 | 1306 | Must select some files in the IDE or set test.class 1307 | Must select some method in the IDE or set test.method 1308 | 1309 | 1310 | 1311 | Some tests failed; see details above. 1312 | 1313 | 1314 | 1319 | 1320 | Must select one file in the IDE or set test.class 1321 | 1322 | 1323 | 1324 | Must select one file in the IDE or set test.class 1325 | Must select some method in the IDE or set test.method 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1342 | 1343 | Must select one file in the IDE or set applet.url 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1355 | 1356 | Must select one file in the IDE or set applet.url 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | --------------------------------------------------------------------------------