本文整理汇总了PHP中CoreUtils::createUploadFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP CoreUtils::createUploadFolder方法的具体用法?PHP CoreUtils::createUploadFolder怎么用?PHP CoreUtils::createUploadFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreUtils
的用法示例。
在下文中一共展示了CoreUtils::createUploadFolder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _output
/**
* @param resource|string $data
* @param string $path
* @param string $relpath
* @param callable $write_callback
* @param string $content_type
*/
private static function _output($data, $path, $relpath, $write_callback, $content_type)
{
if (isset($data)) {
CoreUtils::createUploadFolder($path);
$write_callback($path, $data);
}
CoreUtils::fixPath("{$relpath}?t=" . filemtime($path));
header("Content-Type: image/{$content_type}");
readfile($path);
exit;
}
示例2: renderAppearancePNG
//.........这里部分代码省略.........
$ColorsOutputted = 0;
$SplitTreshold = 12;
$ColumnRightMargin = 20;
// Detect if sprite exists and adjust image size & define starting positions
$SpritePath = SPRITE_PATH . "{$Appearance['id']}.png";
$SpriteExists = file_exists($SpritePath);
if ($SpriteExists) {
$SpriteSize = getimagesize($SpritePath);
$Sprite = Image::preserveAlpha(imagecreatefrompng($SpritePath));
$SpriteHeight = $SpriteSize[HEIGHT];
$SpriteWidth = $SpriteSize[WIDTH];
$SpriteRealWidth = $SpriteWidth + $SpriteRightMargin;
$OutWidth = $SpriteRealWidth;
$OutHeight = $SpriteHeight;
} else {
$SpriteRealWidth = 0;
}
$origin = array('x' => $SpriteExists ? $SpriteRealWidth : $TextMargin, 'y' => 0);
// Get color groups & calculate the space they take up
$ColorGroups = ColorGroups::get($Appearance['id']);
$CGCount = count($ColorGroups);
$CGFontSize = round($NameFontSize / 1.25);
$CGVerticalMargin = $NameVerticalMargin;
$GroupLabelBox = Image::saneGetTTFBox($CGFontSize, $FontFile, 'ABCDEFGIJKLMOPQRSTUVWQYZabcdefghijklmnopqrstuvwxyz');
$ColorNameBox = Image::saneGetTTFBox($ColorNameFontSize, $PixelatedFontFile, 'AGIJKFagijkf');
$CGsHeight = $CGCount * ($GroupLabelBox['height'] + $CGVerticalMargin * 2 + $ColorCircleSize);
// Get export time & size
$ExportTS = "Generated at: " . Time::format(time(), Time::FORMAT_FULL);
$ExportFontSize = round($CGFontSize / 1.5);
$ExportBox = Image::saneGetTTFBox($ExportFontSize, $FontFile, $ExportTS);
// Check how long & tall appearance name is, and set image width
$NameBox = Image::saneGetTTFBox($NameFontSize, $FontFile, $Name);
$OutWidth = $origin['x'] + max($NameBox['width'], $ExportBox['width']) + $TextMargin;
// Set image height
$OutHeight = max($origin['y'] + ($NameVerticalMargin * 4 + $NameBox['height'] + $ExportBox['height'] + $CGsHeight), $OutHeight);
// Create base image
$BaseImage = Image::createTransparent($OutWidth, $OutHeight);
$BLACK = imagecolorallocate($BaseImage, 0, 0, 0);
// If sprite exists, output it on base image
if ($SpriteExists) {
Image::copyExact($BaseImage, $Sprite, 0, 0, $SpriteWidth, $SpriteHeight);
}
// Output appearance name
$origin['y'] += $NameVerticalMargin * 2;
Image::writeOn($BaseImage, $Name, $origin['x'], $NameFontSize, $BLACK, $origin, $FontFile);
$origin['y'] += $NameVerticalMargin;
// Output generation time
Image::writeOn($BaseImage, $ExportTS, $origin['x'], $ExportFontSize, $BLACK, $origin, $FontFile);
$origin['y'] += $NameVerticalMargin;
if (!empty($ColorGroups)) {
$LargestX = 0;
$LargestLabel = '';
$AllColors = ColorGroups::getColorsForEach($ColorGroups);
foreach ($ColorGroups as $cg) {
$CGLabelBox = Image::saneGetTTFBox($CGFontSize, $FontFile, $cg['label']);
Image::calcRedraw($OutWidth, $OutHeight, $CGLabelBox['width'] + $TextMargin, $GroupLabelBox['height'] + $NameVerticalMargin + $CGVerticalMargin, $BaseImage, $origin);
Image::writeOn($BaseImage, $cg['label'], $origin['x'], $CGFontSize, $BLACK, $origin, $FontFile, $GroupLabelBox);
$origin['y'] += $GroupLabelBox['height'] + $CGVerticalMargin;
if ($CGLabelBox['width'] > $LargestX) {
$LargestX = $CGLabelBox['width'];
$LargestLabel = $cg['label'];
}
if (!empty($AllColors[$cg['groupid']])) {
foreach ($AllColors[$cg['groupid']] as $c) {
$ColorNameLeftOffset = $ColorCircleSize + $ColorCircleRMargin;
$CNBox = Image::saneGetTTFBox($ColorNameFontSize, $PixelatedFontFile, $c['label']);
$WidthIncrease = $ColorNameLeftOffset + $CNBox['width'] + $TextMargin;
$HeightIncrease = max($ColorCircleSize, $CNBox['height']) + $CGVerticalMargin;
Image::calcRedraw($OutWidth, $OutHeight, $WidthIncrease, $HeightIncrease, $BaseImage, $origin);
Image::drawCircle($BaseImage, $origin['x'], $origin['y'], $ColorCircleSize, $c['hex'], $BLACK);
$yOffset = 2;
Image::writeOn($BaseImage, $c['label'], $origin['x'] + $ColorNameLeftOffset, $ColorNameFontSize, $BLACK, $origin, $PixelatedFontFile, $ColorNameBox, $yOffset);
$origin['y'] += $HeightIncrease;
$ColorsOutputted++;
$TotalWidth = $ColorNameLeftOffset + $CNBox['width'];
if ($TotalWidth > $LargestX) {
$LargestX = $TotalWidth;
$LargestLabel = $c['label'];
}
}
}
if ($ColorsOutputted > $SplitTreshold) {
Image::calcRedraw($OutWidth, $OutHeight, 0, $NameVerticalMargin, $BaseImage, $origin);
$origin['y'] = $NameVerticalMargin * 4 + Image::saneGetTTFBox($NameFontSize, $FontFile, $Name)['height'] + Image::saneGetTTFBox($ExportFontSize, $FontFile, $ExportTS)['height'];
$origin['x'] += $LargestX + $ColumnRightMargin;
$ColorsOutputted = 0;
$LargestX = 0;
} else {
$origin['y'] += $NameVerticalMargin;
}
}
}
$FinalBase = Image::createWhiteBG($OutWidth, $OutHeight);
Image::drawSquare($FinalBase, 0, 0, array($OutWidth, $OutHeight), null, $BLACK);
Image::copyExact($FinalBase, $BaseImage, 0, 0, $OutWidth, $OutHeight);
if (!CoreUtils::createUploadFolder($OutputPath)) {
Response::fail('Failed to create render directory');
}
Image::outputPNG($FinalBase, $OutputPath, $FileRelPath);
}