private function imgdata2pic($imgdata) { $data = explode(',', $imgdata); $data1 = explode(';', $data[0]); $type = explode('/', $data1[0]); $material = new material(); $img_info = $material->imgdata2pic($data[1], $type[1]); return $img_info[0]; }
public function imgdata2pic($imgdata) { //生成图片 $data = explode(',', $imgdata); $data1 = explode(';', $data[0]); $type = explode('/', $data1[0]); $material = new material(); $img_info = $material->imgdata2pic($data[1], $type[1]); $img_info = $img_info[0]; $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']); return $image_info; }
public function preview_pic() { $material_pic = new material(); if ($this->input['base64'] && $this->input['Filedata']) { //$img = base64_decode(str_replace('data:image/png;base64,', '', urldecode($this->input['Filedata']))); $info = $material_pic->imgdata2pic(urldecode($this->input['Filedata'])); $return = $info[0]['host'] . $info[0]['dir'] . $info[0]['filepath'] . $info[0]['filename']; } if ($_FILES['Filedata']) { $img_info = $material_pic->addMaterial($_FILES); $return = array('id' => $this->input['id'], 'img_path' => $img_info['url']); } $this->addItem($return); $this->output(); }
public function update_indexpic() { $block_id = intval($this->input['block_id']); $site_id = intval($this->input['site_id']); $page_id = intval($this->input['page_id']); $page_data_id = intval($this->input['page_data_id']); $content_type = intval($this->input['content_type']); $client_type = intval($this->input['client_type']); $indexpic = $this->input['indexpic']; if ($indexpic) { include_once ROOT_PATH . 'lib/class/material.class.php'; $mate = new material(); $pic = $mate->imgdata2pic($indexpic); $pic = $pic[0]; if ($pic && is_array($pic)) { $p['host'] = $pic['host']; $p['dir'] = $pic['dir']; $p['filepath'] = $pic['filepath']; $p['filename'] = $pic['filename']; } } if (!$p) { $this->addItem('false'); $this->output(); } if ($block_id) { $this->obj->update(array('indexpic' => serialize($p)), $block_id, 'block'); } else { if ($site_id) { $this->obj->update_block_relation(array('indexpic' => serialize($p)), $site_id, $page_id, $page_data_id, $content_type, $client_type); } } $this->addItem('true'); $this->output(); }
public function screenshotForTemplate() { $intTemplateId = intval($this->input['id']); $strIndexpic = $this->input['indexpic']; if (!$intTemplateId || !$strIndexpic) { $this->errorOutput('NO ID OR DATA'); } if (!class_exists('material')) { include ROOT_PATH . 'lib/class/material.class.php'; } $mate = new material(); $pic = $mate->imgdata2pic($strIndexpic); $pic = $pic[0]; $p = array(); if ($pic && is_array($pic)) { $p['host'] = $pic['host']; $p['dir'] = $pic['dir']; $p['filepath'] = $pic['filepath']; $p['filename'] = $pic['filename']; } if (empty($p)) { $this->errorOutput('截图失败'); } $this->db->update_data(array('indexpic' => addslashes(serialize($p))), 'program_template', 'id=' . $intTemplateId); $this->addItem($p); $this->output(); }
/** * */ public function get_title_pic() { //参数 //$title = "公安部派员督办东莞扫黄 重点打击保护伞"; $title = trim($this->input['title']); $fontface = './data/宋体-粗体.ttf'; //$width = '800'; $width = $this->input['width']; //$height = '60'; $height = $this->input['height']; $fontcolor = array(17, 92, 147); $bgcolor = array(195, 232, 254); $fontsize = ($height - $height / 2) / 4 * 3; $angle = '0'; $x = $height - $height / 2; $y = ($height - $fontsize) / 2 + $fontsize; //生成图片 $image = imagecreatetruecolor($width, $height); $bg_color = imagecolorallocate($image, $bgcolor[0], $bgcolor[1], $bgcolor[2]); imagefill($image, 0, 0, $bg_color); $color = imagecolorallocate($image, $fontcolor[0], $fontcolor[1], $fontcolor[2]); imagettftext($image, $fontsize, $angle, $x, $y, $color, $fontface, $title); header("Content-Type:image/jpeg"); $rand = rand(10000, 99999); $dir = './data/' . $rand . '.jpg'; imagejpeg($image, $dir); imagedestroy($image); //上传图片到图片服务器 $file = file_get_contents($dir); include_once ROOT_PATH . 'lib/class/material.class.php'; $material = new material(); $re = $material->imgdata2pic(base64_encode($file), 'jpg'); //删除图片 if ($re) { unlink($dir); } //返回图片地址 $this->addItem($re); $this->output(); }