Chinatsu is an image mixing utility. She accepts 3 or 4 arguments: First two arguments are input PPM images. Only images with the header "P6 255" are accepted. Images with extra comments (such as the ones produced by GIMP) will not be parsed properly. Both images must be the same size. Third argument is the output file name. Fourth argument, if specified, causes Chinatsu to reorder the output pixels: by default, Chinatsu will mix in the secondary image at even scanlines. Specifying the fourth argument causes the secondary image to be mixed in at odd scanlines instead. Chinatsu usually terminates in one of three ways: * Successfully: in which case the output image will be written and nothing is written to stdout. * Failure due to IO: failed to read input, write output, or parse image headers. An "error" message will be printed to stdout. * Failure due to size mismatch: can not mix images because the two input images are of different sizes. A "size error" message will be printed to stdout. Examples: gcc chinatsu.c -o chinatsu ./chinatsu a.ppm b.ppm even_output.ppm ./chinatsu a.ppm b.ppm odd_output.ppm odd ./chinatsu a.ppm a.ppm double_size.ppm The output image contains the two input images mixed together, in such a way that it displays differently depending on which downsampling algorithm is used: when every other pixel is sampled, the secondary image will be visible. When pixels are averaged, the primary image will be visible. This produces output that are fun to use on image bulletin board websites that use low quality downsampling algorithms to create thumbnails -- the full size image may look completely different from the thumbnail. Also, some image viewers (such as FastStone image viewer) will downsample using a fast method first, pause a bit, then downsample using a high quality method. For those viewers, you get to see both input images in a split second. Chinatsu may compress the color range of the input images if the differences between them are too great. This is done using a fairly efficient search algorithm, implemented in deeply nested loops. These loops are the main source of obfuscation for this code. To improve output quality, Chinatsu also uses a built-in pseudorandom number generator for dithering. gcc 4.4.3 may complain about printf not using a string literal for format string. gcc 4.5.3 does not complain.