Php 图像大小调整不起作用
我正在使用以下代码,但无法调整图像大小,即使Php 图像大小调整不起作用,php,codeigniter,image-resizing,Php,Codeigniter,Image Resizing,我正在使用以下代码,但无法调整图像大小,即使$this->image\u lib->resize()返回true,也不知道出了什么问题: if(file_exists($_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace('_','-',$image))) { $config['source_image'] = $_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace(
$this->image\u lib->resize()
返回true,也不知道出了什么问题:
if(file_exists($_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace('_','-',$image)))
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".str_replace('_','-',$image);
}
else if (!file_exists("./uploads/avatars/".$image) || $image=="")
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT'].'/uploads/avatars/photo.jpg';
}
else
{
$config['source_image'] = $_SERVER['DOCUMENT_ROOT']."/uploads/avatars/".$image;
}
$config['image_library'] = 'gd2';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['dynamic_output'] = TRUE;
$config['width'] = $width;
$config['height'] = $height;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
尝试使用新的_图像标记:
$config['new_image'] = '/path/to/new_image.jpg';
最好在CodeIgniter中使用SimpleImage.php作为助手
$source=base_url().'/uploads/avatars/photo.jpg';
$image = new SimpleImage();
$image->load($source);
$image->resize(600,400);
$image->save($name_and_location);
尝试使用echo$this->image_lib->display_errors();还要确保文件夹和图像本身具有正确的权限:)是的权限也是777,这就是为什么我想知道这有什么问题。请尝试使用
$config['overwrite']=TRUE
并执行打印($config)代码>以确保所有选项都按预期设置。好的,我刚知道此库实际上正在重新调整大小,但根据我的给定值的最佳拟合近似值,并且不在磁盘上重新调整物理大小。