コード例 #1
0
/**
 * Flaming Shame Raster to SVG converter
 *
 * @author  Eric Meyers, Amelia Bellamy-Royds, Robin Cafolla
 * @arg     string url      Takes a single string url or path to local image to
 *                          convert from raster to SVG.
 */
if (count($argv) < 1) {
    throw new \RuntimeException('Too few arguments passed to converter');
}
$url = $argv[1];
$img = loadImage($url);
if (!!$img) {
    header('Content-type: image/svg+xml');
    echo generateSVG($img);
} else {
    echo "<a href=\"{$url}\">Bad image file</a>";
}
/**
 * Generates svg from raster
 *
 * @param GDImageIdentifier $img    Raster image to convert to svg
 * @return string                   SVG xml
 */
function generateSVG($img)
{
    $w = imagesx($img);
    // image width
    $h = imagesy($img);
    // image height
コード例 #2
0
ファイル: generateall.php プロジェクト: Gyebro/rajzteszt
                         mysqli_query($con, $sql2);
                     } else {
                         // Also save to result record
                         $discarded++;
                         $sql2 = "REPLACE INTO results (DRAWINGID, USERID, STAGE, SWLS, SHS, HAPPY, INVALID) ";
                         $sql2 .= "VALUES ('" . $drawingID . "','" . $userID . "','" . $stage . "','" . $swls . "','" . $shs . "','" . $happy . "','" . $invalid . "')";
                         mysqli_query($con, $sql2);
                     }
                     generateSVGc($drawingID, $d, $fit, $annotated, $label);
                 } else {
                     // This is a sketch-test
                     $sql2 = "REPLACE INTO results (DRAWINGID, USERID, STAGE, SWLS, SHS, HAPPY, INVALID) ";
                     $sql2 .= "VALUES ('" . $drawingID . "','" . $userID . "','" . $stage . "','" . $swls . "','" . $shs . "','" . $happy . "','" . $invalid . "')";
                     mysqli_query($con, $sql2);
                     // Generate drawing
                     generateSVG($drawingID, $d);
                 }
                 // end if stage check
                 $generated++;
                 if ($generated % 500 == 0) {
                     echo $generated . "</br>";
                     flush();
                     ob_flush();
                 }
             }
             // end if skipping
         }
         echo "Generated " . $generated . " drawings</br>";
         echo "Accepted " . $accepted . " circle-tests (" . 100 * $accepted / ($accepted + $discarded) . "%)</br>";
     }
 }