├── README.md ├── NEWS ├── tests ├── 1x1-inv.txt ├── dalsnuten-jp2a-2000x2000-md5.txt ├── Makefile ├── test-term.txt ├── jp2a.jpg ├── grind.jpg ├── logo-40x25-gray.jpg ├── dalsnuten-640x480-gray-low.jpg ├── 10h.txt ├── html-title.txt ├── html-raw.txt ├── 40x40.txt ├── normal.txt ├── flip-xy-invert.txt ├── normal-clear.txt ├── normal-b.txt ├── dalsnuten-invert.txt ├── dalsnuten-normal.txt ├── grind.txt ├── grind-blue.txt ├── grind-green.txt ├── grind-red.txt ├── logo-30.txt ├── 110x30-i-b.txt ├── dalsnuten-80x49-inv.txt ├── dalsnuten-color.txt ├── 2xnormal-b.txt ├── logo.html ├── normal-verbose.txt ├── dalsnuten-256.html ├── dalsnuten-256-light.html ├── run-tests.sh ├── grind-color.txt ├── dalsnuten-640x480-gray-low.txt ├── dalsnuten-640x480-rgb-low.txt ├── grind-2grayscale-fill.txt ├── 160x49.txt └── grind-fill.txt ├── INSTALL ├── src ├── Makefile.am ├── aspect_ratio.c ├── html.c ├── jp2a.c ├── term.c ├── curl.c ├── options.c └── image.c ├── AUTHORS ├── include ├── round.h ├── aspect_ratio.h ├── image.h ├── jp2a.h └── options.h ├── autogen.sh ├── .gitignore ├── Makefile.am ├── BUGS ├── configure.ac ├── README ├── man └── jp2a.1 ├── ChangeLog ├── LICENSES └── COPYING /README.md: -------------------------------------------------------------------------------- 1 | README -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See ChangeLog 2 | -------------------------------------------------------------------------------- /tests/1x1-inv.txt: -------------------------------------------------------------------------------- 1 | ' 2 | -------------------------------------------------------------------------------- /tests/dalsnuten-jp2a-2000x2000-md5.txt: -------------------------------------------------------------------------------- 1 | 8004000 2 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | check: test 2 | 3 | test: 4 | ./run-tests.sh 5 | -------------------------------------------------------------------------------- /tests/test-term.txt: -------------------------------------------------------------------------------- 1 | Terminal type 'dummy-term' not recognized. 2 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | See the README file for building and installation instructions. 2 | -------------------------------------------------------------------------------- /tests/jp2a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cslarsen/jp2a/HEAD/tests/jp2a.jpg -------------------------------------------------------------------------------- /tests/grind.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cslarsen/jp2a/HEAD/tests/grind.jpg -------------------------------------------------------------------------------- /tests/logo-40x25-gray.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cslarsen/jp2a/HEAD/tests/logo-40x25-gray.jpg -------------------------------------------------------------------------------- /tests/dalsnuten-640x480-gray-low.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cslarsen/jp2a/HEAD/tests/dalsnuten-640x480-gray-low.jpg -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = jp2a 2 | jp2a_SOURCES = aspect_ratio.c html.c term.c curl.c jp2a.c options.c image.c 3 | AM_CPPFLAGS = -I../include 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | jp2a is written by Christian Stigen Larsen 2 | 3 | This program uses dynamically linked libraries from other authors. 4 | For an overview, see the file LICENSES. 5 | -------------------------------------------------------------------------------- /include/round.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 Christian Stigen Larsen 3 | * Distributed under the GNU General Public License (GPL) v2. 4 | */ 5 | 6 | #ifndef INC_JP2A_ROUND_H 7 | # define ROUND(xfloat) (int) ( 0.5f + xfloat ) 8 | #endif 9 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | autoreconf -vi 3 | 4 | while (( "$#" )); do 5 | if [ $1 == "-c" ]; then 6 | ./configure --with-jpeg-prefix=/usr/local \ 7 | --with-curl-config=`which curl-config` 8 | fi 9 | shift 10 | done 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.o 3 | Makefile 4 | Makefile.in 5 | aclocal.m4 6 | autom4te.cache 7 | compile 8 | config.h 9 | config.h.in 10 | config.log 11 | config.status 12 | configure 13 | depcomp 14 | install-sh 15 | missing 16 | src/.deps 17 | src/jp2a 18 | stamp-h1 19 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | VERSION = @VERSION@ 2 | SUBDIRS = src 3 | man_MANS = man/jp2a.1 4 | EXTRA_DIST = tests/??*.txt tests/??*.html tests/??*.jpg tests/run-tests.sh tests/Makefile include/??*.h man/jp2a.1 LICENSES 5 | 6 | test: check 7 | 8 | check: all 9 | $(MAKE) -C tests check 10 | -------------------------------------------------------------------------------- /include/aspect_ratio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 Christian Stigen Larsen 3 | * Distributed under the GNU General Public License (GPL) v2. 4 | */ 5 | 6 | #ifndef INC_JP2A_ASPECT_RATIO_H 7 | 8 | void aspect_ratio(const int jpeg_width, const int jpeg_height); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /tests/10h.txt: -------------------------------------------------------------------------------- 1 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2 | MMNNMMMMMMMMMMMMMNXXWMMMMMMMMMMM 3 | MW:'XMMMMMMMMMMx. .oWMMMMMMMMM 4 | M0..xN;.';'.;OM00NX' .XWo::;.,OM 5 | MO oN. 'NN, .NMMMx .0MWOkoc cM 6 | MO oN. .xx. ,WWO, ;cxX. ;k. ;X 7 | Mx oN. .lclxNM0llllllxWxcldoclO 8 | W; ,XN' ;MMMMMMMMMMMMMMMMMMMMMMM 9 | MWNMMMNNNMMMMMMMMMMMMMMMMMMMMMMM 10 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 11 | -------------------------------------------------------------------------------- /tests/html-title.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |20 | XNMMWk0M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MMMMMMMMMMMMMMMMMMMMMMMM 32 | MMMMNl ,0MMMMMMMMMMMMMMMMMMMMMMMMMMN: cNMMMMMMMMMMMMMMMMMMMMMMMM 33 | MMMMMKo:lOWMMMMMMMMMMMMMMMMMMMMMMMMMMNc ... .OMMMMMMMMMMMMMMMMMMMMMMMM 34 | MMMMX0OkO0KWMMWK00000XMN0xxxOXWMMMMMMN: ;okkx; .dMMMMMMMWNKkxxxxOXWMMMMMM 35 | MMMWd'''''cKMMXl'''''dkc'....;dXMMMMMNc.;oKMMMM0, dMMMMMW0o:,......;o0WMMMM 36 | MMMWc '0MMK, .. .:0MMMMNkkXNMMMMMWo dMMMMKl' ,OWMMM 37 | MMMWc '0MMK, ;KMMMWNWMMMMMMMMx. .xMMMWl ,0MMM 38 | MMMWc '0MMK, lNMMMMMMMMMMMMMd .OMMMN: .','. dMMM 39 | MMMWc '0MMK, .;c;. .OMMMMMMMMMMMMWl cNMMMNc ,ok0K0l. cWMM 40 | MMMWc '0MMK, 'xXNXd. oMMMMMMMMMMMMK; .xMMMMNc.lKWMMMMK, :NMM 41 | MMMWc '0MMK, lWMMMWo cNMMMMMMMMMMWd. :XMMMMWkxNMMMMWXx' ;XMM 42 | MMMWc '0MMK, lWMMMMO. ;XMMMMMMMMMMK, .OMMMMMMWWMMWXkl;. ;XMM 43 | MMMWc '0MMK, lWMMMMK, ,KMMMMMMMMMNc .oWMMMMMMMMW0o;. ;XMM 44 | MMMWc '0MMK, lWMMMMX; ,KMMMMMMMMNo. :XMMMMMMMMKl' .,. ;XMM 45 | MMMWc '0MMK, lWMMMM0' ;XMMMMMMMWx. ,0MMMMMMMM0; ,d0; ;XMM 46 | MMMWc '0MMK, lMMMMWd cWMMMMMMWk. .xNNNNNNWMNc ;KWN: ;XMM 47 | MMMWc '0MMK, ;0WMWO' dMMMMMMM0' .;:::::l0MO' .xMMN: :NMM 48 | MMMWc '0MMK, 'ldl' '0MMMMMMK; .xMx. .xMMK, ,OKN 49 | MMMWc '0MM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xxxxxddxxddollcclooooc;;,,,,,,,,,,,,,'''...................................;clddlccc;;:;:;:lddd::,',';,lolcc;:: 42 | ,;;;:::ccccclllcllccc:::::clcc;;;;;,''........................................ 43 | '',,,;;;::::::::::::;;;,,,,,,;;,''''''................................... 44 | ..''',,,;;;;;;;,,,,,,,''''.....'''......................... 45 | ......''''''''''''''''.......................... 46 | ............''................................ 47 | ........................................... 48 | ................................... ........ 49 | ...'''...',,,,,,,,,,,,,,,,,,,''''',,;;;;;;;;;,. ......... 50 | ....','.',:ldxdddxxxxxxddooddollllooolllllllcc:. ...... 51 | ......',;cox0XX0kkkxxdl:,',cc,....,''''......''. 52 | .....,:lodOWMWOxxxdxxl,'.',............ 53 | .....';;cxKWMMMWXXKOOx;'''...... 54 | .'';,;;;cd0XWMWX0xoc;''....... 55 | ......,;:cdxkkxocc:;,''..... 56 | .......',;;:::;,,''............ 57 | ........'''''................. 58 | .. .................. . 59 | .............. 60 | . . 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |69 |
20 | ........................................................................................'''''''',,,,,,,,;;;;;;::::::ccccccccclll 21 | ........................ ............................................''''''''',,,,,,,,;;;;;;:::::::cccccccc 22 | .................... ..........................................''''''''',,,,,,,;;;;;;::::::ccccccc 23 | .......... .......................................'''''''',,,,,,,;;;;;;:::::::ccccc 24 | .... ..................................''''''''',,,,,;;;;;;;;::::::cccc 25 | ...............................'''''''',,,,,,,;;;;;;::::::::c 26 | ..............................''''''',,,,,,;;;;;;:::::::: 27 | .............................''''''',,,,,,,;;;;;;:::::: 28 | ............................'''''''',,,,,,,;;;;;::::: 29 | ............................''''''',,,,,,;;;;;;;::: 30 | ..............................''''''',,,,,,;;;;;;;: 31 | ............................''''''',,,,,,,,;;;;; 32 | ............................'''''''',,,,,,,,;;;; 33 | ..........................'''''''',,,,,,,,;;;; 34 | ...........................''''''',,,,,,;;;;;; 35 | ...........................'''''',,,,,,;;;;;; 36 | ........................''''''',,,,,,,;;;;; 37 | ...'''... .........................'''''',,,,,,,;;;;;;: 38 | .....'',;cccldddxxxxxxxdc,. .........................''''''',,,,,,;;;;;;::: 39 | ..;:lodddddxxxxxxkkkkkkkkkOOOOOOkdl:,'......................''''''',,,,,,;;;;;;;:::: 40 | :;;'..... ...... .,coddddddxxxxxkkkkkkkOOOOOOOOOO0000000000Oxxdoc:,............'''''',,,,,,,;;;;;;::::::c 41 | ddooolllccc:::;;;;;;;;::;;::clloolccccoxxkkkkkkkkkkkkkOOO0000KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK0xol::loooxxdxdxdl:::ddkOkOxklclooxdd 42 | kxxxdddooooolllollooodddddolooxxxxxkOO000000000000000KKKKKKXXXXXXXXXXXXXXXXXXXNNNNNNNNNNNNNNNNNNNNNNNWWWWWWWWWWWWWWWWWWWWWWWWWWW 43 | OOkkkxxxddddddddddddxxxkkkkkkxxkOOOOOO000KKKKXKKKKKXXXXXXXXXXXXXXXXXXXXXXNNNNNNNNNNNNNNNWNNNNNNNNNNNWWWWWWWWWWWWWWWWWWWWWWMMMMMM 44 | 00OOOkkkxxxxxxxkkkkkkkOOOO00000OOO00KKKKKKKKKXXXXXXXXXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNWWWWNNNNNWWWWWWWWWWWWWWWWWWWMMMMMMMMMMMMMMM 45 | K00000OOOOOOOOOOOOOOOO0000KKKKKKK0000KKKXXXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWMMMMMMMMMMMMMMMMMMM 46 | KKK000000000OO000000000KKKKKKKXXXXXKKKKXXXXXXXNNNNNNNNNNNNNNNNNNNNNNNNNNNWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWMMMMMMMMMMMMMMMMMMM 47 | XKKKKK00000000000KKKKKKKKKXXXXXXXXXXXXXXXXXNNNNNNNNWWWWWWNNNNNWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWMMMMMMM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MMMMMMMMMMMMW 64 | MWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWMMMMWWMMMMMMMMMMMMMMMMMMMMMMWWWWMMWMWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 65 | WWWWWWWWWWWWWWWWWWWWWMMMMWWWWMMMMMWMMMMMMMMMMMMMMMMMMMMMMMWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWMM 66 | WWWWWWWMWWWWWWMWMWWWMMMMWMWMMMMMMMMMMMMMMMMMMMMWMMWMMWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 67 | MWWWMWMMMMMWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 68 |69 |
tag. 27 | 28 | CHANGES SINCE 1.0.1 (svnversion 427) 29 | - Using span- instead of b-tags in HTML output. 30 | 31 | CHANGES SINCE 1.0.0 (svnversion 421) 32 | - Added option --html-title=... 33 | - Added option --html-raw 34 | 35 | CHANGES SINCE 0.9.22 36 | - License changed from "GPL v2 or later" to "GPL v2". This is just because 37 | I want to review the v3 license before deciding to apply it to jp2a, as it 38 | might require me to add things to the program. 39 | - Minor code changes (in image.c) 40 | - Distribution now also contains HTML manual pages for systems that do not support UNIX man. 41 | - Version bumped to 1.0.0 (stable) 42 | 43 | CHANGES SINCE 0.9.21 (rev. 412) 44 | - Text color output is a bit more colorful. 45 | - HTML-output is now Firefox-friendly. 46 | - Added --html-fill to enable/disable background colors on HTML output. 47 | - Options --background=light or =dark now affects HTML output background. 48 | 49 | CHANGES SINCE 0.9.20 50 | - Added color output for text (ANSI colors) and HTML (CSS colors). 51 | - Changed default HTML fontsize from 4 to 8 pt. 52 | - Fixed a bug that produced incorrect output when using --output and --html. 53 | - Fixed a bug that gave incorret --term-fit when vieweing multiple files. 54 | 55 | CHANGES SINCE 0.9.19 56 | - A bash script is used for testing now. 57 | - The tests were updated to use --width=78 (the old default) where appropriate. 58 | - Cygwin support was added. 59 | - term.h is now also sought in ncurses/term.h (for Cygwin support). 60 | - The help text was shrunk. 61 | 62 | CHANGES SINCE 0.9.18 63 | - Default running mode is now "jp2a --term-fit" if you have --enable-termlib (which is also default). 64 | - New options --term-fit, --term-width, --term-height to automatically fit image to terminal display. 65 | - New options --background=dark and --background=light so you don't have to bother with --invert. 66 | - Much better output quality as all source pixels are now read. 67 | - Configure now accepts --enable-termlib (default) or --disable-termlib. 68 | - Bugfix: In some cases, the last pixel(s) of the source images were not read. 69 | - Will now gracefully exit if jpeg color precision is other than 8 bits per channels. 70 | 71 | CHANGES SINCE 0.9.17 72 | - Bugfix: No more crashes when reading non-JPEG files on Windows. 73 | - New option: --output=file, send output to given file 74 | - New options: -x for shorthand --flipx, and -y for --flipy. 75 | - New options: --red, --green, --blue. 76 | - More natural RGB to Grayscale calculation. 77 | - Updated manuals. 78 | - Cleaner code. 79 | - Faster code (most evident in large images). 80 | 81 | CHANGES SINCE 0.9.16 82 | - New feature: Download-support on win32 binary builds. 83 | - Added option to --clear screen before writing each output image. 84 | - Updated tests for win32 cygwin environment (but still incomplete). 85 | 86 | CHANGES SINCE 0.9.15 AND 0.9.14 87 | - New feature: Now follow HTTP redirects when downloading. 88 | - Cleaner and faster code. 89 | - Cleaner package organization. 90 | - Improved `make test'. 91 | - Binary is larger becase of debug-symbols; remove with `make install-strip'. 92 | - Added HTML-manual for win32 binary distribution. 93 | 94 | CHANGES SINCE 0.9.13 95 | - Minor bugfix: --chars now correctly accepts minimum two chars. 96 | - Changed package layout (added src/ and tests/). 97 | - Added `make test' target. 98 | 99 | CHANGES SINCE 0.9.12 100 | - Bugfix: Fixed bug when viewing several files (in clear(), yadds wasn't completely cleared) 101 | - Minor code cleanup. 102 | 103 | CHANGES SINCE 0.9.11 104 | - Some Linux build failed on this: curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); 105 | This has been removed, and works well for the Linux distro tested on. 106 | 107 | CHANGES SINCE 0.9.10 108 | - New feature: Can now download images from URLs (requires libcurl) 109 | - New feature: Added --debug (-d) for debug output with libcurl 110 | - configure: Added --enable-curl and --with-curl-config=PATH 111 | 112 | CHANGES SINCE 0.9.9 113 | - Using both --width and --height is equivalent to using --size 114 | - Now correctly calculates width and height if one of --width or --height is used 115 | 116 | CHANGES SINCE 0.9.8 117 | - New feature: Added --flipx and --flipy options to flip the output image. 118 | - New feature: Added --html and --html-fontsize for XHTML 1.0 output. 119 | - Bugfix: The bugfix from 0.9.6 sneaked back into the 0.9.8 release, and is now removed. 120 | - Code changes: The code is a little bit cleaner, and faster now for big output dimensions 121 | - Added reference to The Independent JPEG Group in the man page, as the libjpeg license requires that. 122 | - The help text now fits inside 80 characters in width. 123 | - Default mode changed from --width=70 to --width=78 124 | 125 | CHANGES SINCE 0.9.7 126 | - Minor portability issues resolved (regarding size_t usage) 127 | - Moved some redundant help text to the man page 128 | - Updated and expanded man page 129 | 130 | CHANGES SINCE 0.9.6 131 | - Minor bugfix, for some images, the last output line would be a "black" line, 132 | this has been fixed with the use of ROUND in dst_y calculations. 133 | 134 | CHANGES SINCE 0.9.5 135 | - Fixed a major bug in the clear() function that overwrote the yadds buffer. 136 | The program should work much better now, especially on multiple input files. 137 | 138 | CHANGES SINCE 0.9.4 139 | - The option --border can now be specified simply as -b 140 | - New option --invert or -i to invert output image 141 | 142 | CHANGES SINCE 0.9.3 143 | - jp2a now exits with error when no files are specified 144 | - Function signatures changed; added const where applicable 145 | - Reintroduced use of malloc 146 | - Added check for alloca in configure.ac 147 | 148 | CHANGES SINCE 0.9.2 149 | - When reading multiple files, malloc complained when freeing memory. Using 150 | alloca now instead, which does not complain (although it may seem a buffer 151 | overrun is lurking somewhere). 152 | - Not using exit(), using return codes. If error occurs, we always stop. 153 | - Using `cat file.jpg | jp2a -' now does not print help message along with 154 | image. 155 | 156 | CHANGES SINCE 0.9.1 157 | - Much better output results, due to more accurate normalization and removal of 158 | missing scanlines in output image. 159 | - Default mode is now "--width=70" instead of "--size=80x25", as this preserves 160 | JPEG aspect ratio in output. 161 | - Configure does not check for memset function anymore 162 | - to_dst_x and to_dst_y are now correct 163 | 164 | CHANGES SINCE 0.9.0 165 | - Added --border option 166 | - Fixed buffer overrun bug when using big output dimensions 167 | - Minor code cleanup 168 | - Note that to_dst_x and to_dst_y in code might be wrong 169 | -------------------------------------------------------------------------------- /tests/160x49.txt: -------------------------------------------------------------------------------- 1 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 3 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 4 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 5 | MMMMMMMMMMMMMMM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MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 46 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 47 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 48 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 49 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 50 | -------------------------------------------------------------------------------- /LICENSES: -------------------------------------------------------------------------------- 1 | jp2a is distributed under the GNU General Public License v2. See the file 2 | COPYING for a copy of that license, and how you can apply that license to make 3 | derivative works. 4 | 5 | Although I do make use of other libraries, the source distribution does not 6 | include any source-code from these. However, the win32 version comes with 7 | precompiled library files, so I copy the licenses here. 8 | 9 | jp2a makes use of the JPEG library by the Independent JPEG Group. See 10 | http://www.ijg.org 11 | 12 | jp2a makes use of libcurl, which has the following license: 13 | 14 | COPYRIGHT AND PERMISSION NOTICE 15 | 16 | Copyright (c) 1996 - 2006, Daniel Stenberg,. 17 | 18 | All rights reserved. 19 | 20 | Permission to use, copy, modify, and distribute this software for any purpose 21 | with or without fee is hereby granted, provided that the above copyright notice 22 | and this permission notice appear in all copies. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 30 | OR OTHER DEALINGS IN THE SOFTWARE. 31 | 32 | Except as contained in this notice, the name of a copyright holder shall 33 | not be used in advertising or otherwise to promote the sale, use or other 34 | dealings in this Software without prior written authorization of the 35 | copyright holder. 36 | 37 | The jp2a win32 binary distribution comes with zlib1.dll from 38 | http://www.zlib.org. The zlib license is as follows: 39 | 40 | /* zlib.h -- interface of the 'zlib' general purpose compression library 41 | version 1.2.3, July 18th, 2005 42 | 43 | Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler 44 | 45 | This software is provided 'as-is', without any express or implied 46 | warranty. In no event will the authors be held liable for any damages 47 | arising from the use of this software. 48 | 49 | Permission is granted to anyone to use this software for any purpose, 50 | including commercial applications, and to alter it and redistribute it 51 | freely, subject to the following restrictions: 52 | 53 | 1. The origin of this software must not be misrepresented; you must not 54 | claim that you wrote the original software. If you use this software 55 | in a product, an acknowledgment in the product documentation would be 56 | appreciated but is not required. 57 | 2. Altered source versions must be plainly marked as such, and must not be 58 | misrepresented as being the original software. 59 | 3. This notice may not be removed or altered from any source distribution. 60 | 61 | Jean-loup Gailly jloup@gzip.org 62 | Mark Adler madler@alumni.caltech.edu 63 | 64 | */ 65 | 66 | The jp2a win32 binary distribution comes with precompiled OpenSSL binaries from 67 | http://www.openssl.org. These have the following license: 68 | 69 | LICENSE ISSUES 70 | ============== 71 | 72 | The OpenSSL toolkit stays under a dual license, i.e. both the conditions of 73 | the OpenSSL License and the original SSLeay license apply to the toolkit. 74 | See below for the actual license texts. Actually both licenses are BSD-style 75 | Open Source licenses. In case of any license issues related to OpenSSL 76 | please contact openssl-core@openssl.org. 77 | 78 | OpenSSL License 79 | --------------- 80 | 81 | /* ==================================================================== 82 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. 83 | * 84 | * Redistribution and use in source and binary forms, with or without 85 | * modification, are permitted provided that the following conditions 86 | * are met: 87 | * 88 | * 1. Redistributions of source code must retain the above copyright 89 | * notice, this list of conditions and the following disclaimer. 90 | * 91 | * 2. Redistributions in binary form must reproduce the above copyright 92 | * notice, this list of conditions and the following disclaimer in 93 | * the documentation and/or other materials provided with the 94 | * distribution. 95 | * 96 | * 3. All advertising materials mentioning features or use of this 97 | * software must display the following acknowledgment: 98 | * "This product includes software developed by the OpenSSL Project 99 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 100 | * 101 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 102 | * endorse or promote products derived from this software without 103 | * prior written permission. For written permission, please contact 104 | * openssl-core@openssl.org. 105 | * 106 | * 5. Products derived from this software may not be called "OpenSSL" 107 | * nor may "OpenSSL" appear in their names without prior written 108 | * permission of the OpenSSL Project. 109 | * 110 | * 6. Redistributions of any form whatsoever must retain the following 111 | * acknowledgment: 112 | * "This product includes software developed by the OpenSSL Project 113 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 114 | * 115 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 116 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 117 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 118 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 119 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 120 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 121 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 122 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 123 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 124 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 125 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 126 | * OF THE POSSIBILITY OF SUCH DAMAGE. 127 | * ==================================================================== 128 | * 129 | * This product includes cryptographic software written by Eric Young 130 | * (eay@cryptsoft.com). This product includes software written by Tim 131 | * Hudson (tjh@cryptsoft.com). 132 | * 133 | */ 134 | 135 | Original SSLeay License 136 | ----------------------- 137 | 138 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 139 | * All rights reserved. 140 | * 141 | * This package is an SSL implementation written 142 | * by Eric Young (eay@cryptsoft.com). 143 | * The implementation was written so as to conform with Netscapes SSL. 144 | * 145 | * This library is free for commercial and non-commercial use as long as 146 | * the following conditions are aheared to. The following conditions 147 | * apply to all code found in this distribution, be it the RC4, RSA, 148 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 149 | * included with this distribution is covered by the same copyright terms 150 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 151 | * 152 | * Copyright remains Eric Young's, and as such any Copyright notices in 153 | * the code are not to be removed. 154 | * If this package is used in a product, Eric Young should be given attribution 155 | * as the author of the parts of the library used. 156 | * This can be in the form of a textual message at program startup or 157 | * in documentation (online or textual) provided with the package. 158 | * 159 | * Redistribution and use in source and binary forms, with or without 160 | * modification, are permitted provided that the following conditions 161 | * are met: 162 | * 1. Redistributions of source code must retain the copyright 163 | * notice, this list of conditions and the following disclaimer. 164 | * 2. Redistributions in binary form must reproduce the above copyright 165 | * notice, this list of conditions and the following disclaimer in the 166 | * documentation and/or other materials provided with the distribution. 167 | * 3. All advertising materials mentioning features or use of this software 168 | * must display the following acknowledgement: 169 | * "This product includes cryptographic software written by 170 | * Eric Young (eay@cryptsoft.com)" 171 | * The word 'cryptographic' can be left out if the rouines from the library 172 | * being used are not cryptographic related :-). 173 | * 4. If you include any Windows specific code (or a derivative thereof) from 174 | * the apps directory (application code) you must include an acknowledgement: 175 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 176 | * 177 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 178 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 179 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 180 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 182 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 183 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 184 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 185 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 186 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 187 | * SUCH DAMAGE. 188 | * 189 | * The licence and distribution terms for any publically available version or 190 | * derivative of this code cannot be changed. i.e. this code cannot simply be 191 | * copied and put under another distribution licence 192 | * [including the GNU Public Licence.] 193 | */ 194 | -------------------------------------------------------------------------------- /src/options.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 Christian Stigen Larsen 3 | * Distributed under the GNU General Public License (GPL) v2. 4 | */ 5 | 6 | #ifdef HAVE_CONFIG_H 7 | #include "config.h" 8 | #endif 9 | 10 | #include 11 | 12 | #ifdef HAVE_STRING_H 13 | #include 14 | #endif 15 | 16 | #ifdef HAVE_STDLIB_H 17 | #include 18 | #endif 19 | 20 | #ifdef HAVE_CURSES_H 21 | #include 22 | #endif 23 | 24 | #ifdef HAVE_TERM_H 25 | #include 26 | #endif 27 | 28 | #include "jp2a.h" 29 | #include "options.h" 30 | 31 | // Default options 32 | int verbose = 0; 33 | int auto_height = 1; 34 | int auto_width = 0; 35 | 36 | int width = 37 | #ifdef FEAT_TERMLIB 38 | 0; 39 | #else 40 | 78; 41 | #endif 42 | 43 | int height = 0; 44 | int use_border = 0; 45 | int invert = 1; 46 | int flipx = 0; 47 | int flipy = 0; 48 | int html = 0; 49 | int colorfill = 0; 50 | int convert_grayscale = 0; 51 | int html_fontsize = 8; 52 | int html_bold = 1; 53 | const char* html_title = "jp2a converted image"; 54 | int html_rawoutput = 0; 55 | int debug = 0; 56 | int clearscr = 0; 57 | int term_width = 0; 58 | int term_height = 0; 59 | int usecolors = 0; 60 | 61 | int termfit = 62 | #ifdef FEAT_TERMLIB 63 | TERM_FIT_AUTO; 64 | #else 65 | 0; 66 | #endif 67 | 68 | #define ASCII_PALETTE_SIZE 256 69 | char ascii_palette[ASCII_PALETTE_SIZE + 1] = " ...',;:clodxkO0KXNWM"; 70 | 71 | // Default weights, must add up to 1.0 72 | float redweight = 0.2989f; 73 | float greenweight = 0.5866f; 74 | float blueweight = 0.1145f; 75 | 76 | // calculated in parse_options 77 | float RED[256], GREEN[256], BLUE[256], GRAY[256]; 78 | 79 | const char *fileout = "-"; // stdout 80 | 81 | const char* version = PACKAGE_STRING; 82 | const char* copyright = "Copyright 2006-2016 Christian Stigen Larsen"; 83 | const char* license = "Distributed under the GNU General Public License (GPL) v2."; 84 | const char* url = "https://github.com/cslarsen/jp2a"; 85 | 86 | void print_version() { 87 | fprintf(stderr, "%s\n%s\n%s\n", version, copyright, license); 88 | } 89 | 90 | void help() { 91 | print_version(); 92 | 93 | fputs( 94 | "\n" 95 | #ifdef FEAT_CURL 96 | "Usage: jp2a [ options ] [ file(s) | URL(s) ]\n\n" 97 | 98 | "Convert files or URLs from JPEG format to ASCII.\n\n" 99 | #else 100 | "Usage: jp2a [ options ] [ file(s) ]\n\n" 101 | 102 | "Convert files in JPEG format to ASCII.\n\n" 103 | #endif 104 | "OPTIONS\n" 105 | " - Read images from standard input.\n" 106 | " --blue=N.N Set RGB to grayscale conversion weight, default is 0.1145\n" 107 | " -b, --border Print a border around the output image.\n" 108 | " --chars=... Select character palette used to paint the image.\n" 109 | " Leftmost character corresponds to black pixel, right-\n" 110 | " most to white. Minimum two characters must be specified.\n" 111 | " --clear Clears screen before drawing each output image.\n" 112 | " --colors Use ANSI colors in output.\n" 113 | " -d, --debug Print additional debug information.\n" 114 | " --fill When used with --color and/or --html, color each character's\n" 115 | " background color.\n" 116 | " -x, --flipx Flip image in X direction.\n" 117 | " -y, --flipy Flip image in Y direction.\n" 118 | #ifdef FEAT_TERMLIB 119 | " -f, --term-fit Use the largest image dimension that fits in your terminal\n" 120 | " display with correct aspect ratio.\n" 121 | " --term-height Use terminal display height.\n" 122 | " --term-width Use terminal display width.\n" 123 | " -z, --term-zoom Use terminal display dimension for output.\n" 124 | #endif 125 | " --grayscale Convert image to grayscale when using --html or --colors\n" 126 | " --green=N.N Set RGB to grayscale conversion weight, default is 0.5866\n" 127 | " --height=N Set output height, calculate width from aspect ratio.\n" 128 | " -h, --help Print program help.\n" 129 | " --html Produce strict XHTML 1.0 output.\n" 130 | " --html-fill Same as --fill (will be phased out)\n" 131 | " --html-fontsize=N Set fontsize to N pt, default is 4.\n" 132 | " --html-no-bold Do not use bold characters with HTML output\n" 133 | " --html-raw Output raw HTML codes, i.e. without the section etc.\n" 134 | " --html-title=... Set HTML output title\n" 135 | " -i, --invert Invert output image. Use if your display has a dark\n" 136 | " background.\n" 137 | " --background=dark These are just mnemonics whether to use --invert\n" 138 | " --background=light or not. If your console has light characters on\n" 139 | " a dark background, use --background=dark.\n" 140 | " --output=... Write output to file.\n" 141 | " --red=N.N Set RGB to grayscale conversion weight, default 0.2989f.\n" 142 | " --size=WxH Set output width and height.\n" 143 | " -v, --verbose Verbose output.\n" 144 | " -V, --version Print program version.\n" 145 | " --width=N Set output width, calculate height from ratio.\n" 146 | "\n" 147 | #ifdef FEAT_TERMLIB 148 | " The default mode is `jp2a --term-fit --background=dark'.\n" 149 | #else 150 | " The default mode is `jp2a --width=78 --background=dark'.\n" 151 | #endif 152 | " See the man-page for jp2a for more detailed help text.\n" 153 | "\n", stderr); 154 | 155 | fprintf(stderr, "Project homepage on %s\n", url); 156 | fprintf(stderr, "Report bugs to <%s>\n", PACKAGE_BUGREPORT); 157 | } 158 | 159 | void precalc_rgb(const float red, const float green, const float blue) { 160 | int n; 161 | for ( n=0; n<256; ++n ) { 162 | RED[n] = ((float) n) * red / 255.0f; 163 | GREEN[n] = ((float) n) * green / 255.0f; 164 | BLUE[n] = ((float) n) * blue / 255.0f; 165 | GRAY[n] = ((float) n) / 255.0f; 166 | } 167 | } 168 | 169 | void parse_options(int argc, char** argv) { 170 | // make code more readable 171 | #define IF_OPTS(sopt, lopt) if ( !strcmp(s, sopt) || !strcmp(s, lopt) ) 172 | #define IF_OPT(sopt) if ( !strcmp(s, sopt) ) 173 | #define IF_VARS(format, v1, v2) if ( sscanf(s, format, v1, v2) == 2 ) 174 | #define IF_VAR(format, v1) if ( sscanf(s, format, v1) == 1 ) 175 | 176 | int n, files, fit_to_use; 177 | 178 | for ( n=1, files=0; n ASCII_PALETTE_SIZE ) { 236 | fprintf(stderr, 237 | "Too many ascii characters specified (max %d)\n", 238 | ASCII_PALETTE_SIZE); 239 | exit(1); 240 | } 241 | 242 | // don't use sscanf, we need to read spaces as well 243 | strcpy(ascii_palette, s+8); 244 | continue; 245 | } 246 | 247 | fprintf(stderr, "Unknown option %s\n\n", s); 248 | help(); 249 | exit(1); 250 | 251 | } // args ... 252 | 253 | if ( !files ) { 254 | fputs("No files specified.\n\n", stderr); 255 | help(); 256 | exit(1); 257 | } 258 | 259 | #ifdef FEAT_TERMLIB 260 | if ( (width || height) && termfit==TERM_FIT_AUTO ) { 261 | // disable default --term-fit if dimensions are given 262 | termfit = 0; 263 | } 264 | #endif 265 | 266 | if ( termfit ) { 267 | char* err = ""; 268 | 269 | if ( get_termsize(&term_width, &term_height, &err) <= 0 ) { 270 | fputs(err, stderr); 271 | fputc('\n', stderr); 272 | exit(1); 273 | } 274 | 275 | #ifdef __CYGWIN__ 276 | // On Cygwin, if I don't decrement term_width, then you'll get extra 277 | // blank lines for some window sizes, hence we decrease by one. 278 | --term_width; 279 | #endif 280 | 281 | fit_to_use = termfit; 282 | 283 | if ( termfit == TERM_FIT_AUTO ) { 284 | // use the smallest of terminal width or height 285 | // to guarantee that image fits in display. 286 | 287 | if ( term_width <= term_height ) 288 | fit_to_use = TERM_FIT_WIDTH; 289 | else 290 | fit_to_use = TERM_FIT_HEIGHT; 291 | } 292 | 293 | switch ( fit_to_use ) { 294 | case TERM_FIT_ZOOM: 295 | auto_width = auto_height = 0; 296 | width = term_width - use_border*2; 297 | height = term_height - 1 - use_border*2; 298 | break; 299 | 300 | case TERM_FIT_WIDTH: 301 | width = term_width - use_border*2; 302 | height = 0; 303 | auto_height += 1; 304 | break; 305 | 306 | case TERM_FIT_HEIGHT: 307 | width = 0; 308 | height = term_height - 1 - use_border*2; 309 | auto_width += 1; 310 | break; 311 | } 312 | } 313 | 314 | // only --width specified, calc width 315 | if ( auto_width==1 && auto_height == 1 ) 316 | auto_height = 0; 317 | 318 | // --width and --height is the same as using --size 319 | if ( auto_width==2 && auto_height==1 ) 320 | auto_width = auto_height = 0; 321 | 322 | if ( strlen(ascii_palette) < 2 ) { 323 | fputs("You must specify at least two characters in --chars.\n", 324 | stderr); 325 | exit(1); 326 | } 327 | 328 | if ( (width < 1 && !auto_width) || (height < 1 && !auto_height) ) { 329 | fputs("Invalid width or height specified\n", stderr); 330 | exit(1); 331 | } 332 | 333 | if ( (int)((redweight + greenweight + blueweight)*10000000.0f) != 10000000 ) { 334 | fputs("Weights RED + GREEN + BLUE must equal 1.0\n", stderr); 335 | exit(1); 336 | } 337 | 338 | if ( *fileout == 0 ) { 339 | fputs("Empty output filename.\n", stderr); 340 | exit(1); 341 | } 342 | 343 | precalc_rgb(redweight, greenweight, blueweight); 344 | } 345 | -------------------------------------------------------------------------------- /tests/grind-fill.txt: -------------------------------------------------------------------------------- 1 | '''..,,,;[43ml[0m[43mx[0m[43mo[0m[43mx[0mX[43mO[0mXMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMMMW 2 | '....',',;;:[43mc[0m[43mo[0m[43mo[0m[43mk[0mWM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMWWM 3 | ,'.......,;;;;[43ml[0mOXWMMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMNWW 4 | .......'..'',:[43mo[0m0NMMMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMMMMMMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMNNWMM 5 | .....;,..,,,:[43ml[0m[43mx[0m[43mX[0mMM[47mM[0m[47mM[0m[47mM[0m[47mM[0mW[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0m[47mW[0mWWWWMMMMMMMMMMMMMMMMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMMMMMM 6 | ......,;'[43mc[0m',:[43ml[0m[43mc[0m[43ml[0m[43mx[0mkO0[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mX[0m[47mN[0m[47mN[0mNNNNNNNNNNNNNNNNNWWWWWWMMMMM[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0m[47mM[0mMM 7 | '. ...':.',[43ml[0m[43mc[0m[43mc[0m;;lldkO0[47mK[0m[47mK[0m[47mK[0m[47mX[0mXXXXXXXXXXKKKKKKKKKXXXXXXNNNWW[43mW[0m[43mW[0m[43mW[0mMMM[43mM[0m[43mW[0mWWWWWWWWWWMMMM 8 | ..........,',,,cxO0000000KKKKKK0O000OOkOO00O000O0KKKKKX[41mX[0m[41mX[0m[41mN[0m[43mN[0m[41mN[0m[41mN[0m[41mX[0m[41mK[0m[41m0[0m[41m0[0m[41m0[0m[41m0[0m[41mK[0mXKK0000OOO 9 | ''......''c:clxkO0000OOkOOkOOxllldxdoll[43mo[0m[43md[0mkOOOk[43mk[0m[43md[0m[43mx[0m[43mk[0mk[43mx[0m[43mx[0m[43mk[0m0[41m0[0m[41mK[0m[41mK[0m[41mK[0m[41mK[0m[41mK[0m[41m0[0m[41mx[0m[41md[0m[41mx[0m[41mx[0m[41mk[0m[41mO[0m0OOOkkxxxd 10 | ...,..;.::kkOOkkkkkkkkxdddoxxo::cllolccldxkkkoxxdxkxkO0[43m0[0m[41m0[0m[41mK[0m[43mK[0m[43mK[0m[43mK[0m[43mK[0m[41m0[0m[41mO[0m[41mk[0m[41mO[0m[41mO[0m[41m0[0m[41m0[0m[43m0[0m[43m0[0m[43mO[0m[43m0[0m[43mO[0mk[43mk[0mk[43mk[0m 11 | ..','.,;:;dkkkxxxxxxoc:cldoddollooodddddxdd[43mx[0m[43mk[0ml[43mx[0m[43mx[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mO[0m[43mO[0m[43mO[0m[43mO[0m[43mO[0m[43mO[0m[43mO[0m[43mO[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mx[0m[43mx[0m 12 | .......,;';[43mc[0mcllcoxxdol[43mo[0m[43mo[0m[43md[0m[43mx[0m[43md[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43md[0m[43mo[0m[43mx[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m 13 | ...''...''',,,:[43mc[0m[43ml[0m[43mo[0m[43mo[0m[43mo[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43mo[0m[43mo[0m[43ml[0m[43md[0m[43md[0m[43md[0m[43mx[0m[43mx[0m[43mk[0m[43mx[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43ml[0m[43md[0m[43mx[0m[43mx[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mk[0m[43mk[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43md[0m[43md[0m[43mo[0m[43md[0m[43md[0m[43mo[0m[43mo[0m[43mo[0m[43mo[0m[43ml[0m[43ml[0m 14 | ....:ccc[43mc[0m[43ml[0m[43mc[0m[43mc[0m[43mc[0m::[43mc[0m[43mc[0m[43mc[0m[43mc[0m[42mc[0m[43ml[0mOXXXXXKk[43mo[0m[43mo[0m[43ml[0m[43ml[0m[43ml[0m[43mo[0m[43md[0m[43mx[0m[43mx[0m[43mk[0m[43md[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mo[0m[43mk[0m[43mk[0m[43mk[0m[43mO[0m[43mO[0m[43mk[0m[43mk[0m[43mx[0m[43md[0m[43mx[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43mx[0m[43md[0m[43mx[0m[43mx[0m[43md[0m[43md[0m[43md[0m[43md[0m[43mo[0m[43ml[0m[43ml[0m[43mo[0m[43md[0m[43md[0m[43mo[0m[43ml[0m[43ml[0m[43ml[0m[43ml[0m 15 | .[47m.[0m[47m.[0m.,ccccl,:[43ml[0m[43mc[0m,::;::[43mo[0m0XNOxNNxk0[43mx[0m[43ml[0m[43mc[0m[43mc[0m[43mo[0m[43mo[0m[43md[0m[43md[0m[43md[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43ml[0m[43mk[0m[43mk[0m[43mk[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43mk[0m[43mx[0m[43mx[0m[43mx[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43mo[0m[42mo[0m[42ml[0m[42mo[0m[42mo[0m[42ml[0m[42ml[0m[42ml[0m[42ml[0m[42ml[0m[42ml[0m[42ml[0m 16 | .'.....,oo':c:.::,[43mc[0m[43md[0mKko0x[47ml[0mWWco0O[43md[0m[43mc[0m;;:[43ml[0m[43mo[0m[43mo[0m[43md[0m[43md[0m[43ml[0m[43ml[0m[43mc[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43md[0m[43mo[0m[43mo[0m[43mo[0m[43mo[0m[43mo[0m[42mo[0m[43mo[0m[43mo[0m[43ml[0m[43ml[0m[42ml[0m[43ml[0m[43ml[0m[43mc[0m[43ml[0m[43mc[0m[42mc[0m[42mc[0m[43ml[0m:::c 17 | .' ........''.',':ll;'[47m:[0ml[47ml[0mOk:''lxl,;;;';[43mo[0m[43ml[0m:;;[43mc[0m[43md[0m[43mx[0m[43mk[0m[43mx[0m[43mo[0m[43mo[0m[43md[0m[43mx[0m[43mx[0m[43md[0m[43mo[0m[43mo[0m[43mo[0m[43md[0m[43ml[0m[42mc[0m[43ml[0m[43mc[0m[43mc[0m[42mc[0m[42m:[0m;[43m:[0m[43mc[0m[43ml[0m[43ml[0m[43mc[0m[43ml[0m[42mc[0m[42mc[0m[43mc[0m: 18 | ... '..;;.':,.'..[47m'[0m[47ml[0m[47mk[0mc[47m.[0m[47mc[0ml,'',',:c:';;,':[43mc[0m:[47m,[0m[41m,[0m,';;;:xo[43mc[0m[43mo[0m[43mo[0ml[43mo[0m[43md[0mod[43ml[0m:::cc;[43ml[0m[43ml[0m[43mc[0m[43mc[0m[43mc[0m::[43mc[0m[43mc[0m:, 19 | [47m [0m... ...''.','...[47m.[0m[47ml[0mc;'.,;',''''[47mc[0m[47md[0m[47mo[0m[47m.[0m[47mc[0mc'....[47m'[0m[47m'[0m'..[47m'[0m[47m;[0mc:,.';c::;;[47mc[0m[47m;[0m.[47m'[0m[47m,[0m[47m'[0m[47m'[0m[47m'[0m[47m'[0m[47m'[0m[47m,[0m[47m'[0m[47m'[0m[47m.[0m[47m.[0m'[47m.[0m[47m.[0m 20 | [47m [0m... ...... ...',';ll;[47m.[0m[47m;[0m:,ccc[47m:[0m[47m,[0m[47m,[0m[47m,[0m[47m,[0m[47m,[0m[47m,[0m[47m,[0m[47m'[0m[47m.[0m..'[47m'[0m[47m.[0m[47m'[0m[47m.[0m[47m [0m........,;;;;'..[47m,[0m[47m.[0m[47m.[0m[47m.[0m[47m.[0m[47m'[0m[47m;[0m[47m,[0m[47m.[0m[47m.[0m[47m [0m [47m.[0m[47m [0m[47m [0m 21 | [47m [0m .[47m.[0m ... [47m [0m[47m.[0m.''.;d,[47ml[0m0Kc[47m.[0m[41mo[0mx[47m,[0mK[41mX[0m[41mX[0ml,cl'.[47m;[0m[47mo[0ml.,;[47m,[0m,'[47m,[0m[47m.[0m[47m [0m ......'....',..[47m.[0m[47m.[0m[47m [0m[47m.[0m[47m.[0m[47m.[0m[47m [0m[47m [0m[47m.[0m[47m.[0m[47m.[0m[47m.[0m 22 | [47m [0m.. ....,,.[47m.[0m;'[47m'[0m::,';;,ccc;[47m,[0m[47m:[0mlc[47m'[0m[47m'[0m[47m'[0m[47m'[0m[47m.[0m,:[47m;[0m;,'..;,,...... ..[42m,[0m,[47m.[0m[47m.[0m[47m.[0m[47m [0m[47m [0m[47m [0m[47m [0m[47m [0m[47m [0m[47m.[0m[47m.[0m[47m.[0m[47m.[0m 23 | ...,[43ml[0mxdx[41mO[0mdx[41mK[0m[41mK[0md:dxlOOOl,lxddol:[47m.[0m,:[47m:[0m,...,[47m;[0m;'.......... .[42m.[0m[42m.[0m.''[47m'[0m[47m'[0m[47m.[0m[47m.[0m..[47m.[0m[47m.[0m'. 24 | ...,c[47ml[0m[47mo[0m[47md[0m[47md[0m[47mx[0m[47mx[0m[47md[0m[47md[0m[47mx[0m[47mx[0m[47mx[0m[47mk[0m[47mk[0m[47mk[0m[47mk[0m[47mk[0mx[47mx[0m[47md[0mdd[47mc[0mdd[47md[0m[47mo[0m[47mc[0m[47m;[0m[47m,[0m[47m;[0m[47m,[0m. ........[42m.[0m[42m.[0m[42m.[0m[42m.[0m';[47m:[0m:;;;[47m;[0m[47m,[0m[47m,[0m; 25 | ........':[47ml[0m[47mo[0m[47mo[0m[47mo[0m[47md[0m[47md[0m[47mx[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47ml[0m[47m;[0m[47m,[0m[47m:[0m[47m:[0m[47m.[0m[47m.[0m[47m.[0m[47m;[0m[47ml[0m[47ml[0m[47ml[0m[47ml[0m[47m:[0m[47m:[0m[47m:[0m[47m;[0m,'...''...... [42m [0m[42m.[0m... .. ..,'..,[47m;[0m[47m:[0m[47m:[0m[47m;[0m 26 | [42m.[0m..;c[47mo[0m[47mo[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47mx[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47md[0m[47mc[0m[47m'[0m[47m'[0m[47m.[0m[47m.[0m[47m [0m[47m [0m[47m [0m[47m.[0m[47mc[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47ml[0m[47mo[0m[47ml[0m[47ml[0m[47ml[0m[47ml[0m[47ml[0m[47ml[0m[47ml[0m[47mc[0m[47mc[0m[47mc[0m:;,[42m.[0m............. .,[47m:[0m[47m:[0m[47mc[0m 27 | .....,c[47mo[0m[47md[0m[47md[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47mx[0m[47md[0m[47mo[0m[47ml[0m[47m.[0m[47m'[0m[47m.[0m[47m [0m[47m.[0m[47ml[0m[47mo[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47md[0m[47md[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47md[0m[47mo[0m[47mo[0m[47mo[0m[47ml[0m[47mc[0m:'';;,',;;,[47m;[0m[47m;[0m[47m:[0m[47mc[0m[47m:[0m[47m:[0m[47m;[0m[47m;[0m[47m;[0m[47m:[0m[47mc[0m[47mc[0m[47m:[0m 28 | [42m.[0m.....'c[47mo[0m[47md[0m[47mx[0m[47mk[0m[47mk[0m[47mk[0mkk[47mk[0m[47mk[0m[47mx[0m[47mx[0m[47mx[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47ml[0m[47mc[0m[47mc[0m[47m:[0m[47m,[0m[47m [0m[47m,[0m[47md[0m[47md[0m[47mx[0m[47mk[0m[47mk[0m[47mx[0m[47mx[0m[47mk[0m[47mk[0m[47mx[0m[47mx[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0mlcccc:,,,,,,;[47m:[0m[47m:[0m[47mc[0m[47m;[0m:[47mc[0m[47m:[0m[47m:[0m[47m:[0m[47mc[0m 29 | ......:[47mo[0m[47mo[0m[47md[0mxkk[47mk[0m[47mk[0mxkxx[47mx[0m[47mx[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47mo[0m[47mo[0m[47ml[0m[47ml[0m[47mc[0m[47m:[0ml[47md[0mxxk[47mk[0m[47mk[0mxxkxx[47mx[0m[47md[0m[47md[0m[47mo[0m[47md[0m[47md[0m[47md[0m[47md[0m[47mo[0m[47mo[0m[47mo[0m[47mo[0m[47md[0m[47mo[0m[47ml[0m[47mo[0m[47ml[0ml;','';;;[47mc[0m[47ml[0m[47mc[0m[47mc[0m[47ml[0m[47ml[0m[47m:[0m[47m:[0m[47m:[0m 30 | -------------------------------------------------------------------------------- /src/image.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2016 Christian Stigen Larsen 3 | * Distributed under the GNU General Public License (GPL) v2. 4 | */ 5 | 6 | #ifdef HAVE_CONFIG_H 7 | #include "config.h" 8 | #endif 9 | 10 | #ifdef HAVE_STDLIB_H 11 | #include 12 | #undef HAVE_STDLIB_H 13 | #endif 14 | 15 | #include 16 | 17 | #ifdef HAVE_STRING_H 18 | #include 19 | #endif 20 | 21 | #include "jpeglib.h" 22 | 23 | #include "aspect_ratio.h" 24 | #include "image.h" 25 | #include "jp2a.h" 26 | #include "options.h" 27 | 28 | #define ROUND(x) (int) ( 0.5f + x ) 29 | 30 | typedef struct Image_ { 31 | int width; 32 | int height; 33 | float *pixel; // luminosity 34 | float *red, *green, *blue; 35 | int *yadds; 36 | float resize_y; 37 | float resize_x; 38 | int *lookup_resx; 39 | } Image; 40 | 41 | void print_border(const int width) { 42 | #ifndef HAVE_MEMSET 43 | int n; 44 | #endif 45 | 46 | #ifdef WIN32 47 | char *bord = (char*) malloc(width+3); 48 | #else 49 | char bord[width + 3]; 50 | #endif 51 | 52 | #ifdef HAVE_MEMSET 53 | memset(bord, '-', width+2); 54 | #else 55 | for ( n=0; n height; ++y ) { 73 | 74 | if ( use_border ) fprintf(f, "|"); 75 | 76 | xstart = 0; 77 | xend = i->width; 78 | xincr = 1; 79 | 80 | if ( flipx ) { 81 | xstart = i->width - 1; 82 | xend = -1; 83 | xincr = -1; 84 | } 85 | 86 | for ( x=xstart; x != xend; x += xincr ) { 87 | 88 | float Y = i->pixel[x + (flipy? i->height - y - 1 : y ) * i->width]; 89 | float Y_inv = 1.0f - Y; 90 | float R = i->red [x + (flipy? i->height - y - 1 : y ) * i->width]; 91 | float G = i->green[x + (flipy? i->height - y - 1 : y ) * i->width]; 92 | float B = i->blue [x + (flipy? i->height - y - 1 : y ) * i->width]; 93 | 94 | const int pos = ROUND((float)chars * (!invert? Y_inv : Y)); 95 | char ch = ascii_palette[pos]; 96 | 97 | const float min = 1.0f / 255.0f; 98 | 99 | if ( !html ) { 100 | const float t = 0.1f; // threshold 101 | const float i = 1.0f - t; 102 | 103 | int colr = 0; 104 | int highl = 0; 105 | 106 | // ANSI highlite, only use in grayscale 107 | if ( Y>=0.95f && R G && R-t>B ) colr = 31; // red 111 | else if ( G-t>R && G-t>B ) colr = 32; // green 112 | else if ( R-t>B && G-t>B && R+G>i ) colr = 33; // yellow 113 | else if ( B-t>R && B-t>G && Y<0.95f ) colr = 34; // blue 114 | else if ( R-t>G && B-t>G && R+B>i ) colr = 35; // magenta 115 | else if ( G-t>R && B-t>R && B+G>i ) colr = 36; // cyan 116 | else if ( R+G+B>=3.0f*Y ) colr = 37; // white 117 | } else { 118 | if ( Y>=0.7f ) { highl=1; colr = 37; } 119 | } 120 | 121 | if ( !colr ) { 122 | if ( !highl ) fprintf(f, "%c", ch); 123 | else fprintf(f, "%c[1m%c%c[0m", 27, ch, 27); 124 | } else { 125 | if ( colorfill ) colr += 10; // set to ANSI background color 126 | fprintf(f, "%c[%dm%c", 27, colr, ch); // ANSI color 127 | fprintf(f, "%c[0m", 27); // ANSI reset 128 | } 129 | 130 | } else { // HTML output 131 | 132 | // either --grayscale is specified (convert_grayscale) 133 | // or we can see that the image is inherently a grayscale image 134 | if ( convert_grayscale || (R min) ) { 135 | // Grayscale image 136 | if ( colorfill ) 137 | print_html_char(f, ch, 138 | ROUND(255.0f*Y*0.5f), ROUND(255.0f*Y*0.5f), ROUND(255.0f*Y*0.5f), 139 | ROUND(255.0f*Y), ROUND(255.0f*Y), ROUND(255.0f*Y)); 140 | else 141 | print_html_char(f, ch, 142 | ROUND(255.0f*Y), ROUND(255.0f*Y), ROUND(255.0f*Y), 143 | 255, 255, 255); 144 | } else { 145 | if ( colorfill ) 146 | print_html_char(f, ch, 147 | ROUND(255.0f*Y*R), ROUND(255.0f*Y*G), ROUND(255.0f*Y*B), 148 | ROUND(255.0f*R), ROUND(255.0f*G), ROUND(255.0f*B)); 149 | else 150 | print_html_char(f, ch, 151 | ROUND(255.0f*R), ROUND(255.0f*G), ROUND(255.0f*B), 152 | 255, 255, 255); 153 | } 154 | } 155 | } 156 | 157 | if ( use_border ) 158 | fputc('|', f); 159 | 160 | if ( html ) 161 | print_html_newline(f); 162 | else 163 | fputc('\n', f); 164 | } 165 | } 166 | 167 | void print_image(const Image* const i, const int chars, FILE *f) { 168 | int x, y; 169 | 170 | #ifdef WIN32 171 | char *line = (char*) malloc(i->width + 1); 172 | #else 173 | char line[i->width + 1]; 174 | #endif 175 | 176 | line[i->width] = 0; 177 | 178 | for ( y=0; y < i->height; ++y ) { 179 | 180 | for ( x=0; x < i->width; ++x ) { 181 | 182 | const float lum = i->pixel[x + (flipy? i->height - y - 1 : y) * i->width]; 183 | const int pos = ROUND((float)chars * lum); 184 | 185 | line[flipx? i->width - x - 1 : x] = ascii_palette[invert? pos : chars - pos]; 186 | } 187 | 188 | fprintf(f, !use_border? "%s\n" : "|%s|\n", line); 189 | } 190 | 191 | #ifdef WIN32 192 | free(line); 193 | #endif 194 | } 195 | 196 | void clear(Image* i) { 197 | memset(i->yadds, 0, i->height * sizeof(int) ); 198 | memset(i->pixel, 0, i->width * i->height * sizeof(float)); 199 | memset(i->lookup_resx, 0, (1 + i->width) * sizeof(int) ); 200 | 201 | if ( usecolors ) { 202 | memset(i->red, 0, i->width * i->height * sizeof(float)); 203 | memset(i->green, 0, i->width * i->height * sizeof(float)); 204 | memset(i->blue, 0, i->width * i->height * sizeof(float)); 205 | } 206 | } 207 | 208 | void normalize(Image* i) { 209 | 210 | float *pixel = i->pixel; 211 | float *red = i->red; 212 | float *green = i->green; 213 | float *blue = i->blue; 214 | 215 | int x, y; 216 | 217 | for ( y=0; y < i->height; ++y ) { 218 | 219 | if ( i->yadds[y] > 1 ) { 220 | 221 | for ( x=0; x < i->width; ++x ) { 222 | pixel[x] /= i->yadds[y]; 223 | 224 | if ( usecolors ) { 225 | red [x] /= i->yadds[y]; 226 | green[x] /= i->yadds[y]; 227 | blue [x] /= i->yadds[y]; 228 | } 229 | } 230 | } 231 | 232 | pixel += i->width; 233 | 234 | if ( usecolors ) { 235 | red += i->width; 236 | green += i->width; 237 | blue += i->width; 238 | } 239 | } 240 | } 241 | 242 | void print_progress(const struct jpeg_decompress_struct* jpg) { 243 | float progress; 244 | int pos; 245 | #define BARLEN 56 246 | 247 | static char s[BARLEN]; 248 | s[BARLEN-1] = 0; 249 | 250 | progress = (float) (jpg->output_scanline + 1.0f) / (float) jpg->output_height; 251 | pos = ROUND( (float) (BARLEN-2) * progress ); 252 | 253 | memset(s, '.', BARLEN-2); 254 | memset(s, '#', pos); 255 | 256 | fprintf(stderr, "Decompressing image [%s]\r", s); 257 | fflush(stderr); 258 | } 259 | 260 | void print_info(const struct jpeg_decompress_struct* jpg) { 261 | fprintf(stderr, "Source width: %d\n", jpg->output_width); 262 | fprintf(stderr, "Source height: %d\n", jpg->output_height); 263 | fprintf(stderr, "Source color components: %d\n", jpg->output_components); 264 | fprintf(stderr, "Output width: %d\n", width); 265 | fprintf(stderr, "Output height: %d\n", height); 266 | fprintf(stderr, "Output palette (%d chars): '%s'\n", (int)strlen(ascii_palette), ascii_palette); 267 | } 268 | 269 | void process_scanline(const struct jpeg_decompress_struct *jpg, const JSAMPLE* scanline, Image* i) { 270 | static int lasty = 0; 271 | const int y = ROUND( i->resize_y * (float) (jpg->output_scanline-1) ); 272 | 273 | // include all scanlines since last call 274 | 275 | float *pixel, *red, *green, *blue; 276 | 277 | pixel = &i->pixel[lasty * i->width]; 278 | red = green = blue = NULL; 279 | 280 | if ( usecolors ) { 281 | int offset = lasty * i->width; 282 | red = &i->red [offset]; 283 | green = &i->green[offset]; 284 | blue = &i->blue [offset]; 285 | } 286 | 287 | while ( lasty <= y ) { 288 | 289 | const int components = jpg->out_color_components; 290 | const int readcolors = usecolors; 291 | 292 | int x; 293 | for ( x=0; x < i->width; ++x ) { 294 | const JSAMPLE *src = &scanline[i->lookup_resx[x]]; 295 | const JSAMPLE *src_end = &scanline[i->lookup_resx[x+1]]; 296 | 297 | int adds = 0; 298 | 299 | float v, r, g, b; 300 | v = r = g = b = 0.0f; 301 | 302 | while ( src <= src_end ) { 303 | 304 | if ( components != 3 ) 305 | v += GRAY[src[0]]; 306 | else { 307 | v += RED[src[0]] + GREEN[src[1]] + BLUE[src[2]]; 308 | 309 | if ( readcolors ) { 310 | r += (float) src[0]/255.0f; 311 | g += (float) src[1]/255.0f; 312 | b += (float) src[2]/255.0f; 313 | } 314 | } 315 | 316 | ++adds; 317 | src += components; 318 | } 319 | 320 | pixel[x] += adds>1 ? v / (float) adds : v; 321 | 322 | if ( readcolors ) { 323 | red [x] += adds>1 ? r / (float) adds : r; 324 | green[x] += adds>1 ? g / (float) adds : g; 325 | blue [x] += adds>1 ? b / (float) adds : b; 326 | } 327 | } 328 | 329 | ++i->yadds[lasty++]; 330 | 331 | pixel += i->width; 332 | 333 | if ( readcolors ) { 334 | red += i->width; 335 | green += i->width; 336 | blue += i->width; 337 | } 338 | } 339 | 340 | lasty = y; 341 | } 342 | 343 | void free_image(Image* i) { 344 | if ( i->pixel ) free(i->pixel); 345 | if ( i->red ) free(i->red); 346 | if ( i->green ) free(i->green); 347 | if ( i->blue ) free(i->blue); 348 | if ( i->yadds ) free(i->yadds); 349 | if ( i->lookup_resx ) free(i->lookup_resx); 350 | } 351 | 352 | void malloc_image(Image* i) { 353 | i->pixel = i->red = i->green = i->blue = NULL; 354 | i->yadds = NULL; 355 | i->lookup_resx = NULL; 356 | 357 | i->width = width; 358 | i->height = height; 359 | 360 | i->yadds = (int*) malloc(height * sizeof(int)); 361 | i->pixel = (float*) malloc(width*height*sizeof(float)); 362 | 363 | if ( usecolors ) { 364 | i->red = (float*) malloc(width*height*sizeof(float)); 365 | i->green = (float*) malloc(width*height*sizeof(float)); 366 | i->blue = (float*) malloc(width*height*sizeof(float)); 367 | } 368 | 369 | // we allocate one extra pixel for resx because of the src .. src_end stuff in process_scanline 370 | i->lookup_resx = (int*) malloc( (1 + width) * sizeof(int)); 371 | 372 | if ( !(i->pixel && i->yadds && i->lookup_resx) || 373 | (usecolors && !(i->red && i->green && i->blue)) ) 374 | { 375 | fprintf(stderr, "Not enough memory for given output dimension\n"); 376 | free_image(i); 377 | exit(1); 378 | } 379 | } 380 | 381 | void init_image(Image *i, const struct jpeg_decompress_struct *jpg) { 382 | int dst_x; 383 | 384 | i->resize_y = (float) (i->height - 1) / (float) (jpg->output_height - 1); 385 | i->resize_x = (float) (jpg->output_width - 1) / (float) (i->width ); 386 | 387 | for ( dst_x=0; dst_x <= i->width; ++dst_x ) { 388 | i->lookup_resx[dst_x] = ROUND( (float) dst_x * i->resize_x ); 389 | i->lookup_resx[dst_x] *= jpg->out_color_components; 390 | } 391 | } 392 | 393 | void decompress(FILE *fp, FILE *fout) { 394 | int row_stride; 395 | struct jpeg_error_mgr jerr; 396 | struct jpeg_decompress_struct jpg; 397 | JSAMPARRAY buffer; 398 | Image image; 399 | 400 | jpg.err = jpeg_std_error(&jerr); 401 | jpeg_create_decompress(&jpg); 402 | jpeg_stdio_src(&jpg, fp); 403 | jpeg_read_header(&jpg, TRUE); 404 | jpeg_start_decompress(&jpg); 405 | 406 | if ( jpg.data_precision != 8 ) { 407 | fprintf(stderr, 408 | "Image has %d bits color channels, we only support 8-bit.\n", 409 | jpg.data_precision); 410 | exit(1); 411 | } 412 | 413 | row_stride = jpg.output_width * jpg.output_components; 414 | 415 | buffer = (*jpg.mem->alloc_sarray)((j_common_ptr) &jpg, JPOOL_IMAGE, row_stride, 1); 416 | 417 | aspect_ratio(jpg.output_width, jpg.output_height); 418 | 419 | malloc_image(&image); 420 | clear(&image); 421 | 422 | if ( verbose ) print_info(&jpg); 423 | 424 | init_image(&image, &jpg); 425 | 426 | while ( jpg.output_scanline < jpg.output_height ) { 427 | jpeg_read_scanlines(&jpg, buffer, 1); 428 | process_scanline(&jpg, buffer[0], &image); 429 | if ( verbose ) print_progress(&jpg); 430 | } 431 | 432 | if ( verbose ) { 433 | fprintf(stderr, "\n"); 434 | fflush(stderr); 435 | } 436 | 437 | normalize(&image); 438 | 439 | if ( clearscr ) { 440 | fprintf(fout, "%c[2J", 27); // ansi code for clear 441 | fprintf(fout, "%c[0;0H", 27); // move to upper left 442 | } 443 | 444 | if ( html && !html_rawoutput ) print_html_start(html_fontsize, fout); 445 | if ( use_border ) print_border(image.width); 446 | 447 | (!usecolors? print_image : print_image_colors) (&image, (int) strlen(ascii_palette) - 1, fout); 448 | 449 | if ( use_border ) print_border(image.width); 450 | if ( html && !html_rawoutput ) print_html_end(fout); 451 | 452 | free_image(&image); 453 | 454 | jpeg_finish_decompress(&jpg); 455 | jpeg_destroy_decompress(&jpg); 456 | } 457 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | --------------------------------------------------------------------------------