本文整理汇总了PHP中sfImage::resizeSimple方法的典型用法代码示例。如果您正苦于以下问题:PHP sfImage::resizeSimple方法的具体用法?PHP sfImage::resizeSimple怎么用?PHP sfImage::resizeSimple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfImage
的用法示例。
在下文中一共展示了sfImage::resizeSimple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
/**
* Apply the transformation to the image and returns the resized image
*/
protected function transform(sfImage $image)
{
list($target_w, $target_h) = $this->computeTargetSize($image->getWidth(), $image->getHeight());
return $image->resizeSimple($target_w, $target_h);
}
示例2: transform
/**
* Apply the transformation to the image and returns the resized image
*/
protected function transform(sfImage $image)
{
$source_w = $image->getWidth();
$source_h = $image->getHeight();
$target_w = $this->width;
$target_h = $this->height;
if (is_numeric($this->width) && $this->width > 0 && $source_w > 0) {
if (!$this->inflate && $target_w > $source_w) {
$target_w = $source_w;
}
if ($this->proportional) {
// Compute the new height in order to keep the aspect ratio
// and clamp it to the maximum height
$target_h = round($source_h / $source_w * $target_w);
if (is_numeric($this->height) && $this->height < $target_h && $source_h > 0) {
$target_h = $this->height;
$target_w = round($source_w / $source_h * $target_h);
}
}
}
if (is_numeric($this->height) && $this->height > 0 && $source_h > 0) {
if (!$this->inflate && $target_h > $source_h) {
$target_h = $source_h;
}
if ($this->proportional) {
// Compute the new width in order to keep the aspect ratio
// and clamp it to the maximum width
$target_w = round($source_w / $source_h * $target_h);
if (is_numeric($this->width) && $this->width < $target_w && $source_w > 0) {
$target_w = $this->width;
$target_h = round($source_h / $source_w * $target_w);
}
}
}
return $image->resizeSimple($target_w, $target_h);
}