doutiao2540 2019-01-18 10:36
浏览 72
已采纳

GD图像调整大小不适用于生产服务器(Amazon EC2 Ubuntu)

I have two dev environment setup

  1. Test - PHP Version 7.0.33-1+ubuntu16.04.1+deb.sury.org+1 + GD headers Version 2.2.5 (as per phpinfo)
  2. Production - PHP Version 7.0.32-0ubuntu0.16.04.1 + GD headers Version 2.1.1 (as per phpinfo)

on Amazon EC2 Ubuntu in which i am trying to use image resizing with codeigniter image manipulation class with this code.

$resizeConfig['image_library']  = 'gd2';
$resizeConfig['source_image']       = $imageName;
$resizeConfig['new_image']      = $imageName;
$resizeConfig['width']              = 320;
$resizeConfig['height']         = 215;
$resizeConfig['maintain_ratio']    = FALSE;
$resizeConfig['quality']            = '100%';
$this->load->library('image_lib');  
$this->image_lib->initialize($resizeConfig);

both the servers are showing GD installed and enabled if i check on PHPINFO()

The problem is TEST Environment works fine with the code and resizing images on the fly. However, PROD server not working with image resizing with the same code. Install GD on PROD with this command

sudo apt-get install php7.0-gd

Please help me out what i am missing over here. Any help is appreciated. TIA.

  • 写回答

1条回答 默认 最新

  • dqv84329 2019-01-21 08:11
    关注

    The code was not enough for production server. since i am working with codeigniter. I had to add following line.

    $this->image_lib->resize();

    after

    $this->image_lib->initialize($resizeConfig);

    But i still wonder how the same code was working with testing server without that additional line.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?