代码对我来说就像一个魅力。但我现在已将文件从一台服务器传输到另一台服务器,但现在无法正常工作。图片正在上传(原始)->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();
}