Example #1
0
function paintr()
{
    global $current_id;
    /*  try
        {*/
    load_current_id(STORE_DIR);
    $current_id++;
    //$filename_jpeg = WORK_DIR . $current_id . ".jpg";
    $filename_svg = WORK_DIR . $current_id . ".svg";
    $filename_svg_final = STORE_DIR . $current_id . ".svg";
    $filename_html = STORE_DIR . $current_id . ".html";
    echo "Begin.<br />";
    echo "ID: " . $current_id . "<br />";
    echo "Get palette.<br />";
    $palette_source = get_palette();
    $palette_name = palette_name($palette_source);
    $palette = palette_entries($palette_source);
    $palette = sort_palette_by_brightness($palette);
    $palette = light_to_dark_or_dark_to_light($palette);
    $palette_tags = palette_tags($palette_source);
    echo "Tags: " . implode(", ", $palette_tags) . "<br />\n";
    //$wordnet_synonims = wordnet_tags_synonims ($palette_tags);
    //echo implode (", ", $wordnet_synonims) . "\n";
    // At the moment flickr API access fails if we don't echo these. Huh?
    echo "Get photo.<br />";
    $photo = photo_from_tags($palette_tags);
    //($wordnet_synonims);
    echo "Get photo user name.<br />";
    $username = photo_user_name($photo);
    echo "Get photo name.<br/>";
    $photo_name = photo_name($photo);
    $file_description = $photoname . ' by ' . $username . ', licensed under the Creative Commons Attribution-ShareAlike License' . '.jpg';
    $filename_jpeg = WORK_DIR . urlencode($file_description);
    echo "Save JPEG.<br />";
    photo_save_jpeg($photo, $filename_jpeg);
    echo "Autotrace.<br />";
    autotrace(count($palette), $filename_jpeg, $filename_svg);
    echo "Delete old file.<br />";
    @unlink($filename_jpeg);
    echo "Load svg.<br />";
    $svg = load_svg($filename_svg);
    echo "Apply palette.<br />";
    $svg = apply_palette_to_svg($palette, $svg);
    echo "Save SVG.<br />";
    save_svg($svg, $filename_svg_final);
    echo "Save writeup.<br />";
    save_writeup($filename_html, $palette_name, $palette, $palette_tags, $photo);
    echo "End.<br />";
    /*    } 
      catch (Exception $e)
        {
          $error = "<h2>" . date ("l dS of F Y at h:i:s A") . "</h2>" .
    	"<h2>An error occurred: " . get_class($e) . "</h2>\n" .
    	"<h3>{$e->getMessage()} ({$e->getCode()})</h3>\n\n" .
    	"file: {$e->getFile()}<br/>\n" .
    	"line: {$e->getLine()}<br/>\n" .
    	"<PRE>" .
    	$e->getTraceAsString() . 
    	"</PRE><br />" ;
          file_put_contents ("./error.html", $error, FILE_APPEND);
          die ();
          }*/
    // When finished, save the id for next time. If we failed, re-use same id.
    save_current_id(STORE_DIR);
    trim_older();
}
Example #2
0
// Copyright 2005 Rob Myers <*****@*****.**>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
require_once 'current_id.php';
load_current_id("./");
// Get the current image id
// Make damn sure it's an int and is in range
$id = $_GET['image'];
if ($id) {
    $id = 0 + $id;
    if ($id < $current_id - 20 || $id < 1) {
        $id = 1;
    } else {
        if ($id > $current_id) {
            $id = $current_id;
        }
    }
} else {
    $id = $current_id;
}