【发布时间】:2013-09-12 06:46:59
【问题描述】:
代码对我来说就像一个魅力。但我现在已将文件从一台服务器传输到另一台服务器,但现在无法正常工作。图片正在上传(原始)-> image.jpg 但调整大小后的其他两张图片 thumb_image.jpg 和 featured_image.jpg 没有上传。不知道是什么问题。
我查看了错误日志,我看到了这 3 行代码
ERROR - 2013-09-08 17:38:26 --> PNG images are not supported.
ERROR - 2013-09-08 17:38:26 --> The path to the image is not correct.
ERROR - 2013-09-08 17:38:26 --> Your server does not support the GD function required to process this type of image.
我不明白图像路径有什么问题,为什么它说 PNG 图像不受支持,因为它工作得很好。
调整大小代码是
public function resizeIMG($imagePath, $filename){
$this->load->library('image_lib');
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = $imagePath;
$configThumb['create_thumb'] = FALSE;
$configThumb['new_image'] = 'thumb_'.$filename;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 260;
$configThumb['height'] = 215;
$configFeatured['image_library'] = 'gd2';
$configFeatured['source_image'] = $imagePath;
$configFeatured['create_thumb'] = FALSE;
$configFeatured['new_image'] = 'featured_'.$filename;
$configFeatured['maintain_ratio'] = TRUE;
$configFeatured['width'] = 800;
$configFeatured['height'] = 500;
$configCropFeatured['image_library'] = 'gd2';
$configCropFeatured['source_image'] = './uploads/featured_'.$filename;
$configCropFeatured['x_axis'] = '0';
$configCropFeatured['y_axis'] = '0';
$configCropFeatured['create_thumb'] = FALSE;
$configCropFeatured['new_image'] = 'featured_'.$filename;
$configCropFeatured['maintain_ratio'] = FALSE;
$configCropFeatured['width'] = 720;
$configCropFeatured['height'] = 250;
$this->image_lib->initialize($configThumb);
$this->image_lib->resize();
$this->image_lib->initialize($configFeatured);
$this->image_lib->resize();
$this->image_lib->initialize($configCropFeatured);
$this->image_lib->crop();
}
【问题讨论】:
-
您可能使用了错误的 image_library,只需测试其他的(GD、GD2、ImageMagick、NetPBM)。 (没有错但没有安装在你的服务器上)查看安装了哪些库使用
phpinfo()
标签: php codeigniter image-processing