本文整理汇总了PHP中Varien_Image::setImageBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Image::setImageBackgroundColor方法的具体用法?PHP Varien_Image::setImageBackgroundColor怎么用?PHP Varien_Image::setImageBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Image
的用法示例。
在下文中一共展示了Varien_Image::setImageBackgroundColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImage
function getImage($src, $xSize = 150, $ySize = 150, $keepRatio = true, $styles = "")
{
if ($src != "") {
$image = new Varien_Image(Mage::getBaseDir('media') . DS . $src);
$image->constrainOnly(false);
$image->keepAspectRatio($keepRatio);
$image->setImageBackgroundColor(0xffffff);
$image->keepTransparency(true);
$image->resize($xSize, $ySize);
$image->save(Mage::getBaseDir('media') . DS . 'stores/cache/' . basename($src));
return "<img style='" . $styles . "' src='" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'stores/cache/' . basename($src) . "'/>";
} else {
return;
}
}
示例2: resizeImg
public function resizeImg($img, $width, $height = false, $customerId = false)
{
if (!isset($customerId)) {
$customerId = $this->_customerId;
}
$_media_dir = Mage::getBaseDir('media') . DS . 'albums' . DS . $customerId . DS;
$imgSize = getimagesize(Mage::getBaseDir('media') . DS . 'albums' . DS . $customerId . DS . $img);
// real image sizes
$imgWidth = $imgSize[0];
$imgHeight = $imgSize[1];
if ($imgWidth > $imgHeight) {
$imgProp = $imgWidth / $imgHeight;
$newWidth = $width;
$newHeight = $width / $imgProp;
} elseif ($imgWidth < $imgHeight) {
$imgProp = $imgHeight / $imgWidth;
$newWidth = $width / $imgProp;
$newHeight = $width;
} elseif ($imgWidth == $imgHeight) {
$newWidth = $newHeight = $width;
}
$cache_dir = $_media_dir . 'cache' . DS . $width . DS;
if (file_exists($_media_dir . $img)) {
if (!is_dir($_media_dir . 'cache' . DS)) {
mkdir($_media_dir . 'cache');
} elseif (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
$_image = new Varien_Image($_media_dir . $img);
$_image->constrainOnly(FALSE);
$_image->keepAspectRatio(TRUE);
$_image->keepFrame(TRUE);
$_image->keepTransparency(TRUE);
$_image->backgroundColor(array(255, 255, 255));
$_image->setImageBackgroundColor(TRUE);
$_image->quality(100);
//$_image->resize($width, $height);
$_image->resize($newWidth, $newHeight);
$_image->save($cache_dir . $img);
return Mage::getBaseUrl() . 'media/albums/' . $customerId . '/cache/' . $width . '/' . $img;
}
return false;
}
示例3: resize_image
/**
* @param $path
*/
protected function resize_image($path)
{
$image = new Varien_Image($path);
$image->constrainOnly(true);
$image->keepAspectRatio(true);
$image->keepFrame(false);
$image->keepTransparency(true);
$image->setImageBackgroundColor(false);
$image->backgroundColor(false);
$image->quality(100);
$image->setWatermarkImageOpacity(0);
$image->resize(120, 120);
$image->save($path);
}