【发布时间】:2011-01-15 01:04:02
【问题描述】:
我希望有人可以帮助我。我正在尝试通过表单上传图像,将其调整为 600px,创建 100px 缩略图,然后将水印图像添加到 600px 版本,但下面的代码只是创建原始图像的两个版本。
$image = $this->upload->data();
$resized = base_url()."images/artwork/".$image['orig_name'];
//Create 600px version
$config = array();
$config['source_image'] = $resized;
$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$config['width'] = 600;
$config['height'] = 600;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
unset($config);
//Add watermark to 600px version
$config = array();
$config['source_image'] = $resized;
$config['image_library'] = 'gd2';
$config['wm_type'] = 'overlay';
$config['wm_overlay_path'] = './images/logo.gif';
$config['wm_vrt_alignment'] = 'middle';
$config['wm_hor_alignment'] = 'center';
$this->image_lib->initialize($config);
$this->image_lib->watermark();
$this->image_lib->clear();
unset($config);
//Create 100px unwatermarked thumbnail
$config = array();
$config['source_image'] = $resized;
$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$config['width'] = 100;
$config['height'] = 100;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
unset($config);
$thumbnail = base_url()."images/artwork/".$image['raw_name']."".$image['file_ext'];
echo "<a href=\"".$resized."\"><img src=\"".$thumbnail."\" /></a>";
【问题讨论】:
标签: php codeigniter image-processing