protected static function _cachePhoto($cache_dir, $file_name, $file_type) { if (!$file_name || !$file_type) { return false; } //生产缓存文件(缩放后的图) $cache_path_name = ROOT_PATH . $cache_dir; $cache_file_path = $cache_path_name . md5($file_name) . '.' . $file_type; //目录不存在,创建目录 if (!is_dir($cache_path_name)) { @mkdir($cache_path_name, 0755, true); } if (!is_file($cache_file_path)) { // if( strstr( $file_name, PhotoM::uploadPath ) ){//旧的存储方式 // image::getobj()->imageinit( ROOT_PATH . $file_name, 1, 800, 800, 0, 0, $cache_file_path )->outimage(); // }else{//新的存储方式 // image::getobj()->imageinit( ROOT_PATH . PhotoM::uploadPath . $file_name, 1, 800, 800, 0, 0, $cache_file_path )->outimage(); // } image::getobj()->imageinit(ROOT_PATH . PhotoM::uploadPath . $file_name, 1, 800, 800, 0, 0, $cache_file_path)->outimage(); } }
public function image() { $tu = '{"std_ratio":0.36618333333333,"real_ratio":1,"x":10,"y":10,"width":173,"height":270,"tu_x":80,"tu_y":60}'; // $tu = isset( $_REQUEST['tu'] ) ? $_REQUEST['tu'] : ''; $tu = json_decode($tu, true); $img_path = HOME_PATH . "images/208.png"; $file_path = HOME_PATH . "images/6.png"; $is_tshirt = 0; $endaddress = HOME_PATH . "images/209.png"; // $img=imagecreatefrompng($endaddress); // $bg = imagecolorallocate($img,255,255,255); // imagecolortransparent($img,$bg); // header("Content-type: image/png"); // imagepng($img,HOME_PATH . "images/300.png"); // throw new Exception( 'exit' ); //使用图片裁剪功能 // image::getobj()->imageinit(HOME_PATH . "images/1.jpg", 2, "50,50", "50,50", HOME_PATH . "images/5.jpg"); //缩放图 // image::getobj()->imageinit( HOME_PATH . "images/3.png", 1, "260", "260" ) // ->outimage(); // throw new Exception( 'exit' ); //使用加图片水印功能 image::getobj()->imageinit($img_path, 3, $file_path, "5", $is_tshirt)->imagescaling2($tu['real_ratio'])->positionim($tu['x'], $tu['y'], $tu['width'], $tu['height'], $tu['tu_x'], $tu['tu_y'])->setbackground(255, 255, 255)->outimage(); }