问题描述:发布或后编辑商品时,商品介绍里面的图片上传正常,而商品主图上传失败,此种情况出现的原因的生成主图缩微图的时候程序异常,主要原因是Web环境配置的兼容性问题 ,大多数环境配置不存在此情况,通过代码排查,我们发现以下报错代码:
setImageOpacity was replaced with setImageAlpha in php-imagick v3.4.3
问题修复:
1、打开文件:frontend/controllers/UploadController.php 103 行
将代码:
\yii\imagine\Image::thumbnail(Def::fileSavePath() . DIRECTORY_SEPARATOR . $filePath, 400, 400, \Imagine\Image\ManipulatorInterface::THUMBNAIL_INSET)->save(Def::fileSavePath() . DIRECTORY_SEPARATOR . $thumbnail, ['quality' => 100]),
修改为:
\yii\imagine\Image::thumbnail(Def::fileSavePath() . DIRECTORY_SEPARATOR . $filePath, 400, 400, \Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND)->save(Def::fileSavePath() . DIRECTORY_SEPARATOR . $thumbnail, ['quality' => 100]),
2、如果是商业版,同理修改:apiserver/controllers/UploadController.php 191行
将代码:
\Imagine\Image\ManipulatorInterface::THUMBNAIL_INSET
修改为:
\Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND
3、完毕!