</ul> <p>Available import formats:</p> <ul> <?php $list = caca_get_import_list(); foreach ($list as $format => $name) { echo '<li>' . htmlspecialchars("{$name} ({$format})") . '</li>'; } ?> </ul> <p>Available export formats:</p> <ul> <?php $list = caca_get_export_list(); foreach ($list as $format => $name) { echo '<li>' . htmlspecialchars("{$name} ({$format})") . '</li>'; } ?> </ul> <p>Available caca fonts:</p> <ul> <?php $list = caca_get_font_list(); foreach ($list as $name) { echo '<li>' . htmlspecialchars("{$name}") . '</li>'; } ?> </ul>
function usage($argc, $argv) { fprintf(STDERR, "Usage: %s [OPTIONS]... <IMAGE>\n", $argv[0]); fprintf(STDERR, "Convert IMAGE to any text based available format.\n"); fprintf(STDERR, "Example : %s -W 80 -f ansi ./caca.png\n\n", $argv[0]); fprintf(STDERR, "Options:\n"); fprintf(STDERR, " -h, --help\t\t\tThis help\n"); fprintf(STDERR, " -v, --version\t\t\tVersion of the program\n"); fprintf(STDERR, " -W, --width=WIDTH\t\tWidth of resulting image\n"); fprintf(STDERR, " -H, --height=HEIGHT\t\tHeight of resulting image\n"); fprintf(STDERR, " -x, --font-width=WIDTH\t\tWidth of output font\n"); fprintf(STDERR, " -y, --font-height=HEIGHT\t\tHeight of output font\n"); fprintf(STDERR, " -b, --brightness=BRIGHTNESS\tBrightness of resulting image\n"); fprintf(STDERR, " -c, --contrast=CONTRAST\tContrast of resulting image\n"); fprintf(STDERR, " -g, --gamma=GAMMA\t\tGamma of resulting image\n"); fprintf(STDERR, " -d, --dither=DITHER\t\tDithering algorithm to use :\n"); $list = caca_get_dither_algorithm_list(caca_create_dither(imagecreate(1, 1))); foreach ($list as $type => $name) { fprintf(STDERR, "\t\t\t%s: %s\n", $type, $name); } fprintf(STDERR, " -f, --format=FORMAT\t\tFormat of the resulting image :\n"); $list = caca_get_export_list(); foreach ($list as $type => $name) { fprintf(STDERR, "\t\t\t%s: %s\n", $type, $name); } }
* * This file is a Php port of "examples/export.c" * which is: * Copyright (c) 2006 Sam Hocevar <*****@*****.**> * All Rights Reserved * * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What the F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ define('WIDTH', 80); define('HEIGHT', 32); $pixels = imagecreatetruecolor(256, 256); $exports = caca_get_export_list(); $file = isset($_FILES['file']) ? $_FILES['file']['tmp_name'] : NULL; $filename = isset($_FILES['file']) ? $_FILES['file']['name'] : NULL; $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : NULL; if (!$format || !array_key_exists($format, $exports)) { header("Content-type: text/html; charset=UTF-8"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>libcaca export test program</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> /*<![CDATA[*/