アップロード後に複数の画像に透かしを適用したい。現在、画像はアップロードされていますが、すべて透かしがなく、アップロードする画像の品質を下げたいと考えています。
public function do_upload()
{
$this->load->library('upload');
$name_array = array();
$files = $_FILES;
$cpt = count($_FILES['userfile1']['name']);
for($i=0; $i<=$cpt-1; $i++)
{
$_FILES['userfile']['name']= $files['userfile1']['name'][$i];
$_FILES['userfile']['type']= $files['userfile1']['type'][$i];
$_FILES['userfile']['tmp_name']= $files['userfile1']['tmp_name'][$i];
$_FILES['userfile']['error']= $files['userfile1']['error'][$i];
$_FILES['userfile']['size']= $files['userfile1']['size'][$i];
$this->upload->initialize($this->set_upload_options());
if($data = $this->upload->do_upload()){
$config['source_image'] = $files['userfile1']['tmp_name'][$i]; //get original image
$config['wm_type'] = 'overlay';
$config['wm_overlay_path'] = './portfolio_img/ninja.png';
$config['quality'] = 50;
$config['wm_vrt_alignment'] = 'bottom';
$config['wm_hor_alignment'] = 'right';
$this->load->library('image_lib', $config);
$this->image_lib->watermark();
}
$name_array[] = $this->upload->data('file_name');
}
return $name_array;
}
private function set_upload_options()
{
//upload an image options
$config = array();
$config['upload_path'] = './portfolio_img/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['overwrite'] = FALSE;
return $config;
}