コード例 #1
0
ファイル: sandphoto.php プロジェクト: fuhongliang/sandphoto
<?php

include "sandphoto.inc";
if (($_FILES["filename"]["type"] == "image/png" || $_FILES["filename"]["type"] == "image/jpeg" || $_FILES["filename"]["type"] == "image/bmp" || $_FILES["filename"]["type"] == "image/tiff" || $_FILES["filename"]["type"] == "image/pjpeg") && $_FILES["filename"]["size"] < 8000000) {
    if ($_FILES["filename"]["error"] > 0) {
        header("Content-Type: text/html");
        print "上传文件错误!";
        return;
    } else {
        $filename = $_FILES["filename"]["tmp_name"];
        $target_type = $_POST["target_type"];
        $container_type = $_POST["container_type"];
        //print "type:$container_type";
        $parser = new PhotoTypeParser();
        $parser->parse('phototype.txt');
        $cw = $parser->get_width($container_type);
        $ch = $parser->get_height($container_type);
        $tw = $parser->get_width($target_type);
        $th = $parser->get_height($target_type);
        $p = new Photo();
        $p->set_container_size($cw, $ch);
        $p->set_target_size($tw, $th);
        $n = $p->put_photo($filename, $_POST["bgcolorid"]);
        // $p->render_image();
        // $p->preview_image();
        $download_name = $n . "张" . $parser->get_name($target_type) . "[以" . $parser->get_name($container_type) . "冲洗].jpg";
        $p->download_image($download_name);
    }
}
コード例 #2
0
ファイル: preview.php プロジェクト: fuhongliang/sandphoto
<?php

include "sandphoto.inc";
$filename = "/var/sandcomp/apache/htdocs/sandphoto/sample.jpg";
$temp_path = "/var/sandcomp/apache/htdocs/sandphoto/temp";
$target_type = $_GET["t"];
$container_type = $_GET["c"];
$bgcolorid = $_GET["b"];
$cacheFilename = "preview-" . $target_type . "-" . $container_type . "-" . $bgcolorid . ".png";
$cachePath = $temp_path . "/" . $cacheFilename;
if (!file_exists($cachePath)) {
    $parser = new PhotoTypeParser();
    $parser->parse('phototype.txt');
    $cw = $parser->get_width($container_type);
    $ch = $parser->get_height($container_type);
    $tw = $parser->get_width($target_type);
    $th = $parser->get_height($target_type);
    $p = new Photo();
    $p->set_container_size($cw, $ch);
    $p->set_target_size($tw, $th);
    $n = $p->put_photo($filename, $bgcolorid);
    $p->preview_image($cachePath);
    system("/usr/local/bin/optipng " . $cachePath . " >/dev/null 2>/dev/null");
}
header("location: temp/" . $cacheFilename);
exit;