예제 #1
0
<?php

//MyPic 图片加水印, 生成缩略图类
// 原始图片
$img1 = './image/test.jpg';
// 水印后的图片
$img2 = './image/test_new.jpg';
// 水印
$water = './image/water.gif';
$img = new image();
// 等比缩放
$img->param($img1)->thumb('./image/test_0.jpg', 200, 200, 0);
// center center 裁剪
$img->param($img1)->thumb('./image/test_1.jpg', 200, 200, 1);
// top left 裁剪
$img->param($img1)->thumb('./image/test_2.jpg', 200, 200, 2);
// 右下角添加水印
$img->param($img1)->water($img2, $water, 9);
/* +-------------------------------------------------------------+
* | Copyright (c) 2008-2009 Diqiye.Com All rights reserved.
* +-------------------------------------------------------------+
* | Info : 图像处理类
* +-------------------------------------------------------------+
*/
class image
{
    // 当前图片
    protected $img;
    // 图像types 对应表
    protected $types = array(1 => 'gif', 2 => 'jpg', 3 => 'png', 6 => 'bmp');
    // image
예제 #2
0
    $save_url .= $ymd . "/";
    if (!file_exists($save_path)) {
        mkdir($save_path);
    }
    //新文件名
    $new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
    //移动文件
    $file_path = $save_path . $new_file_name;
    if (move_uploaded_file($tmp_name, $file_path) === false) {
        alert("上传文件失败。");
    }
    @chmod($file_path, 0644);
    $file_url = $save_url . $new_file_name;
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 0, 'url' => $file_url));
    // echo "<script>alert('文件名:$file_path');</script>";
    include_once 'perImage.php';
    perImage($file_path, 500, false, $file_path);
    include_once 'class_img.php';
    $img = new image();
    $img->param($file_path)->water($file_path, "water.png", 9);
    exit;
}
function alert($msg)
{
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 1, 'message' => $msg));
    exit;
}