0

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


    }
4

1 回答 1

2

日志说Your server does not support the GD function required to process this type of image.这意味着您的服务器主机没有启用 GD 库(或者可能出于某种原因禁止了您正在使用的功能)

您需要联系您的虚拟主机以查看他们是否可以启用 GD。如果没有,您将需要转换您的应用程序以使用不同的库。phpinfo()您可以通过在 PHP 脚本中运行来找出可用的库。如果 GD 被禁用,则很可能相反,ImageMagick已打开 - 您可以查看该页面,一旦您了解基本功能,您就可以将您的应用程序转换为使用 ImageMagick。请确保 ImageMagick(或imagick在 phpinfo() 中的某个位置。如果没有,您可能最好要求您的主机启用任何一个插件。

于 2013-09-08T19:40:58.813 回答