本文整理汇总了PHP中sfImage::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP sfImage::getFilename方法的具体用法?PHP sfImage::getFilename怎么用?PHP sfImage::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfImage
的用法示例。
在下文中一共展示了sfImage::getFilename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
public function transform(sfImage $img)
{
$this->directory = dirname($img->getFilename());
$arr = array_reverse(explode("/", $img->getFilename()));
$this->fileName = $arr[0];
$arr2 = explode(".", $this->fileName);
if (count($arr2) == 1) {
$this->fileName .= '.png';
}
$destDir = '/tmp';
$ccFile = $destDir . DIRECTORY_SEPARATOR . 'cc_' . $this->fileName;
$bwFile = $destDir . DIRECTORY_SEPARATOR . 'bw_' . $this->fileName;
$ccSmallFile = $destDir . DIRECTORY_SEPARATOR . 'cc_s_' . $this->fileName;
$bwSmallFile = $destDir . DIRECTORY_SEPARATOR . 'bw_s_' . $this->fileName;
if (!file_exists($destDir)) {
mkdir($destDir);
}
if ($img->getWidth() > IMG_MAX_WIDTH || $img->getHeight() > IMG_MAX_HEIGHT) {
if ($img->getWidth() > $img->getHeight() * IMG_RATIO) {
$img->resize(IMG_MAX_WIDTH, null);
} else {
$img->resize(null, IMG_MAX_HEIGHT);
}
}
$img->saveAs($ccFile);
$img->greyscale()->saveAs($bwFile);
$smallImg = new sfImage($ccFile);
if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_WIDTH) {
if ($smallImg->getWidth() > $img->getHeight() * IMG_RATIO) {
$smallImg->resize(null, IMG_MAX_HEIGHT);
} else {
$smallImg->resize(IMG_MAX_WIDTH, null);
}
}
if ($smallImg->getWidth() > IMG_SMALL_WIDTH || $smallImg->getHeight() > IMG_SMALL_HEIGHT) {
if ($smallImg->getWidth() > $smallImg->getHeight() * IMG_RATIO) {
$smallImg->resize(null, IMG_SMALL_HEIGHT);
} else {
$smallImg->resize(IMG_SMALL_WIDTH, null);
}
}
$x1 = ($smallImg->getWidth() - IMG_SMALL_WIDTH) / 2;
$y1 = ($smallImg->getHeight() - IMG_SMALL_HEIGHT) / 3;
$smallImg->crop($x1, $y1, IMG_SMALL_WIDTH, IMG_SMALL_HEIGHT)->saveAs($ccSmallFile);
$smallImg->greyscale()->saveAs($bwSmallFile);
}