【问题标题】:Codeigniter resize issue after transferring server传输服务器后的 Codeigniter 调整大小问题
【发布时间】: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


【解决方案1】:

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

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

【讨论】:

  • 是的,已经这样做了,是的,服务器是新设置的,因此该功能未启用。
猜你喜欢
  • 2011-05-18
  • 1970-01-01
  • 2020-01-20
  • 2013-02-01
  • 2015-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多