[英]watermark and upload image on codeigniter
im trying to watermark my image on codeigniter i can watermark image which i have to gave path and that works fine but i want to watermark my image which im going to upload that means i choose files and watermark them and upload it to database so how can i do that here is my image uploading controller 我试图在codeigniter上给我的图像加水印,我可以给必须加路径的图像加水印,并且可以正常工作,但是我想对要上传的图像加水印,这意味着我选择文件并将其加水印并将其上传到数据库,以便我这样做是我的图像上传控制器
Controller 控制者
function add_page() {
$this->access_denied();
//new page add from form process
if($this->input->post('add')) {
$this->form_validation->set_rules('slug', 'slug', 'trim|required|min_length[4]|max_length[200]');
$this->form_validation->set_rules('title', 'title', 'trim|required');
$this->form_validation->set_rules('details', 'details', 'trim|required');
if ($this->form_validation->run()) {
$slug = strip_tags(url_title($this->input->post('slug')));
$title = $this->input->post('title');
$details = $this->input->post('details');
$publish_date = time();
$added_by = $this->session->userdata('full_name');
// if image is uploaded
if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['size']>0) {
$config = array('upload_path' => './uploads/page/',
'allowed_types' => 'jpg|gif|png|jpeg|ico',
'max_size' => 0,
'max_height' => 0,
'max_width' =>0
);
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$image_files = $this->upload->data();z
$this->page_model->add_page($slug, $title, $details, $image_files['file_name'], $publish_date, $added_by);
$this->session->set_flashdata('error_msg', '<div class="alert alert-success" role="alert") New page has been added successfully.</div>');
redirect('page/manage-page');
}
else {
$this->session->set_flashdata('error_msg', $this->upload->display_errors());
redirect('page/add_page');
}
}
else {
$this->page_model->add_page($slug, $title, $details, null,$publish_date,$added_by);
$this->session->set_flashdata('error_msg', '<div class="alert alert-success" role="alert") New page has been added successfully.</div>');
redirect('page/manage-page');
}
}
}
$data = array('page_title' => "Add new page",
'keywords' =>"",
'description' => "",
'image' => "",
'url'=> "",
'author' => "",
'page_content' => $this->load->view('page/add', '', true)
);
$this->load->view('dashboard', $data);
}
i hope it wont freak you out guys but it would be great help for me thanks. 我希望它不会吓到你们,但是对我来说,这将是极大的帮助,谢谢。
You can use codeigniter for Watermarking link 您可以使用codeigniter进行水印链接
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['wm_text'] = 'Copyright 2006 - John Doe';
$config['wm_type'] = 'text';
$config['wm_font_path'] = './system/fonts/texb.ttf';
$config['wm_font_size'] = '16';
$config['wm_font_color'] = 'ffffff';
$config['wm_vrt_alignment'] = 'bottom';
$config['wm_hor_alignment'] = 'center';
$config['wm_padding'] = '20';
$this->image_lib->initialize($config);
$this->image_lib->watermark();
Here is the good code which will help you for the image upload and watermarking 这是很好的代码,它将帮助您进行图像上传和加水印
Image Upload and Watermarking 图片上传和水印
http://demo.codesamplez.com/codeigniter/image-demo http://demo.codesamplez.com/codeigniter/image-demo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.