Ejemplo n.º 1
0
 static function edit()
 {
     $img_name = post('img_name', 'title');
     list($width, $height) = getimagesize($img_name);
     $p_width = post('p_w', 'int');
     $p_height = post('p_h', 'int');
     //先缩放
     $res = imagecreatetruecolor($p_width, $p_height);
     $img = img::open($img_name);
     imagecopyresampled($res, $img, 0, 0, 0, 0, $p_width, $p_height, $width, $height);
     img::clear($img);
     //再裁切
     $new_img = imagecreatetruecolor(post('n_w', 'int'), post('n_h', 'int'));
     imagecopyresampled($new_img, $res, 0, 0, post('t_x', 'int'), post('t_y', 'int'), $p_width, $p_height, $p_width, $p_height);
     $img_name = basename($img_name);
     img::save($new_img, $img_name, dc_file_create);
     http::json(array('error' => 0, 'info' => $img_name), true);
 }