大家好:)预先感谢您对此问题的任何帮助。PHP的ImageMagick图像的多个尺寸 - 无法让它工作
我正在使用CodeIgniter,并且图像上传,旋转和调整大小成功。 这是当我尝试创建多个尺寸的图像,我有点迷路。
这里是我的代码:
// First I make two copies of the origional image - there is no problem here - these always work. I always have the successfully copied images.
$Copy_Mid_Size_File = "Some_Path_For_The_Newly_Copied_Mid_Size_Image"
if(!copy($source_image, $Copy_Mid_Size_File)){
echo "failed to copy $Copy_Mid_Size_File - Please contact the system administrator. \n";
die();
}
$Copy_Thumbnail_Size_File = "Some_Path_For_The_Newly_Copied_Thumbnail_Size_Image"
if(!copy($source_image, $Copy_Thumbnail_Size_File)){
echo "failed to copy $Copy_Thumbnail_Size_File - Please contact the system administrator. \n";
die();
}
// Now I resize for the mid size image
$config['image_library'] = 'imagemagick';
$config['library_path'] = '/usr/bin';
$config['source_image'] = $Copy_Mid_Size_File;
$config['maintain_ratio'] = TRUE;
$config['quality'] = '100%';
$config['master_dim'] = 'auto';
$config['width'] = 200;
$config['height'] = 200;
$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()){
echo $this->image_lib->display_errors();// This has never reported an error yet
echo "Image Re-size for Mid Size Image FAILED!";// This has never reported an error yet
die();
}else{
echo" Mid-Size Re-size Worked!";
}
// Now I try to resize for the Thumbnail
$config['image_library'] = 'imagemagick';
$config['library_path'] = '/usr/bin';
$config['source_image'] = $Copy_Thumbnail_Size_File;
$config['maintain_ratio'] = TRUE;
$config['quality'] = '100%';
$config['master_dim'] = 'auto';
$config['width'] = 50;
$config['height'] = 50;
$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()){
echo $this->image_lib->display_errors();// This has never reported an error yet
echo "Image Re-size for Thumbnail Size Image FAILED!";// This has never reported an error yet
die();
}else{
echo" Thumbnail Re-size Worked!";
}
我总是最后的图像适当数量的正确命名 - 缩略图只是不重新大小 - 没有报告的错误。它总是说成功了。
如果我先将缩略图重新调整大小代码 - 缩略图重新调整大小 - 但中等大小的图像不会。
我意识到还有其他方法来加载库 - 但我不明白为什么第一次重新大小的作品,但第二次没有。
任何想法?
谢谢。 问候, 肯
放在这行代码创建缩略图 之前'$这个 - > image_lib->明确的()' – chhameed
喜哈米德 - 尝试,而我得到的错误“失败图像处理请确认您的服务器支持所选的协议,并且图像库的路径是正确的。“ 奇怪的是,第一个是完全一样的,没有错误 - 但第二个调用了“路径”或“协议”错误。为什么会通过而不是另一个? – KDawg