Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento如何从图像背景中删除黑色图像_Magento - Fatal编程技术网

Magento如何从图像背景中删除黑色图像

Magento如何从图像背景中删除黑色图像,magento,Magento,我是马根托的新手。我对magento中使用的图像感到非常困惑。我已将产品列表中的默认图像大小135x135更改为300X400。但现在的问题是,确切的产品页面图像具有黑色背景图像&而inspect元素显示的大小为267x267 请给我解释一下。我想把图像的大小改为 产品页面为300X400 内部精确的产品图像为300X400 我还使用了缩放效果扩展。悬停时图像不应获得像素化。那么在上传产品图片时,我应该使用什么样的图片大小呢 使用下面的代码 echo $this->helper('cata

我是马根托的新手。我对magento中使用的图像感到非常困惑。我已将产品列表中的默认图像大小135x135更改为300X400。但现在的问题是,确切的产品页面图像具有黑色背景图像&而inspect元素显示的大小为267x267

请给我解释一下。我想把图像的大小改为

  • 产品页面为300X400
  • 内部精确的产品图像为300X400
  • 我还使用了缩放效果扩展。悬停时图像不应获得像素化。那么在上传产品图片时,我应该使用什么样的图片大小呢
  • 使用下面的代码

    echo $this->helper('catalog/image')->init($_product, 'image')->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(300, null)
    

    此代码将调整图像大小而不影响图像比率。如果给定固定的宽度和高度,调整图像大小将失去原创性。

    我在Magento社区中找到了一条评论。修复黑色背景 转到
    GD2.php
    并在第301行之后:

    $this->_fillBackgroundColor($newImage);
    
    请输入以下代码:

    $whitebg=imagecolorallocate($newImage,255,255,255);
    imagefilledrectangle($newImage,0,0,$frameWidth,$frameHeight,$whitebg);
    
    准备好了

    解决方案:

    <?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepTransparency(false); ?>