Update 2011/akari

Format and typo fixes in README.md.

Add try.me.sh as the try section is kind of long. Removed extraneous
make commands in the script and the try section. Added make clobber
first.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-15 04:11:59 -07:00
1 parent 9a516dbcbe
commit 0bef6cfba9
2 files changed
+84 -45

No files matched your search

+61 -45
View File
@@ -1,8 +1,8 @@
# Best of Show - Most Shrinkable
Don Yang
<omoikane@uguu.org>
<http://uguu.org/>
Don Yang
<omoikane@uguu.org>
<http://uguu.org/>
## To build:
@@ -13,7 +13,7 @@ make
## To run:
```sh
./akari [input_file_or_- [output_file_or_- [even]]]
./akari [ input_file | - ] [ output_file | - ] [even]
```
## Try:
@@ -26,16 +26,12 @@ make
make akari2
cat akari2.c
make akari2
./akari2 < akari2.c
./akari2 rot13 < akari2.c
make akari3
cat akari3.c
make akari3
./akari3
make akari4
@@ -44,89 +40,109 @@ cat akari4.c
./akari4
```
You can automate the above by running:
```sh
./try.me.sh
```
## Judges' remarks:
Akari is an image downsampling utility that accepts 3 inout formats:
`Akari` is an image downsampling utility that accepts 3 input formats:
* PGM (netpbm grayscale image). Akari only accept PGM files with this
header: P5 <width> <height> 255. Images with extra comments such as
the ones produced by GIMP will not be parsed properly.
* `PGM` (`netpbm` greyscale image). `Akari` only accepts `PGM` files with this
header: `P5 <width> <height> 255`. Images with extra comments _such as the ones
produced by GIMP will **not be parsed properly**_.
* PPM (netpbm RGB image). Only PPM files with this header are
accepted: P6 <width> <height> 255.
* PPM (netpbm RGB image). Only PPM files with this header are
accepted: `P6 <width> <height> 255`.
* ASCII art (with end of lines in LF bytes only, not CR-LF)
* ASCII art (with end of lines in LF bytes only, _**not** CRLF_!)
Anything that is not parseable as PGM or PPM will be downsampled as ASCII art.
Anything that is not parsable as `PGM` or `PPM` will be downsampled as ASCII art.
## Author's remarks:
Akari is an image downsampling utility. She accepts up to 3 arguments:
`Akari` is an image downsampling utility. She accepts up to 3 arguments:
First argument is the input image. If it's "-" or unspecified, Akari
First argument is the input image. If it's `-` or unspecified, `Akari`
will read from stdin.
Second argument is the output image. If it's "-" or unspecified,
Akari will write to stdout.
Second argument is the output image. If it's `-` or unspecified,
`Akari` will write to stdout.
Third argument, if specified, causes Akari to keep even pixels on even
scanlines. By default Akari will keep odd pixels on odd scanlines.
Third argument, if specified, causes `Akari` to keep even pixels on even
[scanlines](https://en.wikipedia.org/wiki/Scan_line). By default `Akari` will
keep odd pixels on odd [scanlines](https://en.wikipedia.org/wiki/Scan_line).
Examples:
### Examples:
gcc akari.c -o akari
./akari < example.ppm > odd_output.ppm
./akari - - even < example.ppm > even_output.ppm
./akari example.ppm odd_output.ppm
```sh
gcc akari.c -o akari
./akari < example.ppm > odd_output.ppm
./akari - - even < example.ppm > even_output.ppm
./akari example.ppm odd_output.ppm
```
Akari accepts 3 input formats:
* PGM (netpbm grayscale image). Akari only accept PGM files with this
header: P5 <width> <height> 255. Images with extra comments such as
`Akari` accepts 3 input formats:
* `PGM` (`netpbm greyscale image`). `Akari` only accepts `PGM` files with this
header: `P5 <width> <height> 255`. Images with extra comments such as
the ones produced by GIMP will not be parsed properly.
* PPM (netpbm RGB image). Only PPM files with this header are
accepted: P6 <width> <height> 255.
* `PPM` (`netpbm RGB image`). Only `PPM` files with this header are
accepted: `P6 <width> <height> 255`.
* ASCII art (with end of lines in LF bytes only, not CR-LF)
This is useful for decoding some curiously interlaced images, such as
the included example.ppm
Anything that is not parseable as PGM or PPM will be downsampled as
Anything that is not parsable as `PGM` or `PPM` will be downsampled as
ASCII art. Since the source code is formatted as ASCII art, it's only
natural to try:
./akari akari.c akari2.c
```sh
./akari akari.c akari2.c
```
akari2.c is also a valid C program, and accepts up to 1 argument.
`akari2.c` is also a valid C program, and accepts up to 1 argument.
By default, this second program reads text from stdin and writes
expanded output to stdout. If the extra argument is specified, the
output text will also pass through a rot13 filter.
gcc akari2.c -o akari2
./akari2 < input.txt > expanded_output.txt
./akari2 rot13 < input.txt > expanded_and_rot13_output.txt
```sh
gcc akari2.c -o akari2
./akari2 < input.txt > expanded_output.txt
./akari2 rot13 < input.txt > expanded_and_rot13_output.txt
```
You can combine the two programs together to have just a regular rot13
filter:
./akari2 rot13 < input.txt | ./akari > rot13.txt
```sh
./akari2 rot13 < input.txt | ./akari > rot13.txt
```
Of course, we wouldn't stop with just 2 programs, you can downsample
the source *again* and get yet another C program:
./akari < akari.c | ./akari > akari3.c
```sh
./akari < akari.c | ./akari > akari3.c
```
We must go deeper:
./akari < akari.c | ./akari | ./akari > akari4.c
```sh
./akari < akari.c | ./akari | ./akari > akari4.c
```
akari3.c and akari4.c are still (mostly valid) C programs.
"gcc -Wall" will output a few warnings, but still produce output
`akari3.c` and `akari4.c` are still (mostly valid) C programs.
`gcc -Wall` will output a few warnings, but still produce output
executables. The output executables each print a message to stdout.
It takes quite a bit of skill and obfuscation to interleave a
C program 4 levels deep, it's much easier to interleave something like
a brainf#$% program in a C program, for example. For comparison, a
brainf#$% program is embedded inside akari.c
a `brainf#$%` program in a C program, for example. For comparison, a
`brainf#$%` program is embedded inside [akari.c](akari.c).
## Copyright and CC BY-SA 4.0 License:
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
make clobber akari || exit 1
./akari < example.ppm > odd_output.ppm
./akari - - even < example.ppm > even_output.ppm
./akari example.ppm odd_output.ppm
make akari2 || exit 1
cat akari2.c
./akari2 < akari2.c
./akari2 rot13 < akari2.c
make akari3 || exit 1
cat akari3.c
./akari3
make akari4 || exit 1
cat akari4.c
./akari4