gpt4 book ai didi

php - Magento - 调整图像大小,保持宽高比,裁剪超出尺寸的部分

转载 作者:可可西里 更新时间:2023-11-01 01:04:49 25 4
gpt4 key购买 nike

我想在 magento 中调整图像大小以保持其纵横比并使其填充具有另一个纵横比的矩形。

例子:

我的图片是 640x480

我的矩形是 100x50

我希望图像填满所有矩形并裁剪超出它的部分。

我知道 keepFrame(FALSE) - 它不会使图像填充矩形,而是使其适合内部并且不会裁剪任何内容。

此外,如果您熟悉 Wordpress,我想要的是:*add_image_size('home',370,256,true);*

谢谢你:)

最佳答案

看看@

因为 magento 已经更改了页面链接结构,请尝试 http://web.archive.org/web/20140707042130/http://www.magentocommerce.com/boards/viewthread/47269/

<罢工> Crop product thumbnail images to clean square

尝试

<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(120,null); ?>" width="120" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />

关于php - Magento - 调整图像大小,保持宽高比,裁剪超出尺寸的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13732463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com