本文整理汇总了PHP中asset::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP asset::getType方法的具体用法?PHP asset::getType怎么用?PHP asset::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asset
的用法示例。
在下文中一共展示了asset::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateThumbnail
public static function generateThumbnail(asset $srcAsset, thumbParamsOutput $destThumbParamsOutput, &$errDescription)
{
$srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
if (!$fileSync || $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
$errDescription = 'Source asset could has no valid file sync';
return false;
}
$srcPath = $fileSync->getFullPath();
$uniqid = uniqid('thumb_');
$destPath = kConf::get('temp_folder') . "/thumb/{$uniqid}.jpg";
$logPath = $destPath . '.log';
if (!file_exists($srcPath)) {
$errDescription = "Source file [{$srcPath}] does not exist";
return false;
}
if (!is_file($srcPath)) {
$errDescription = "Source file [{$srcPath}] is not a file";
return false;
}
try {
if ($srcAsset->getType() == assetType::FLAVOR) {
// generates the thumbnail
$thumbMaker = new KFFMpegThumbnailMaker($srcPath, $destPath, kConf::get('bin_path_ffmpeg'));
$created = $thumbMaker->createThumnail($destThumbParamsOutput->getVideoOffset());
if (!$created || !file_exists($destPath)) {
$errDescription = "Thumbnail not captured";
return false;
}
$srcPath = $destPath;
$uniqid = uniqid('thumb_');
$destPath = kConf::get('temp_folder') . "/thumb/{$uniqid}.jpg";
}
$quality = $destThumbParamsOutput->getQuality();
$cropType = $destThumbParamsOutput->getCropType();
$cropX = $destThumbParamsOutput->getCropX();
$cropY = $destThumbParamsOutput->getCropY();
$cropWidth = $destThumbParamsOutput->getCropWidth();
$cropHeight = $destThumbParamsOutput->getCropHeight();
$bgcolor = $destThumbParamsOutput->getBackgroundColor();
$width = $destThumbParamsOutput->getWidth();
$height = $destThumbParamsOutput->getHeight();
$scaleWidth = $destThumbParamsOutput->getScaleWidth();
$scaleHeight = $destThumbParamsOutput->getScaleHeight();
$cropper = new KImageMagickCropper($srcPath, $destPath, kConf::get('bin_path_imagemagick'), true);
$cropped = $cropper->crop($quality, $cropType, $width, $height, $cropX, $cropY, $cropWidth, $cropHeight, $scaleWidth, $scaleHeight, $bgcolor);
if (!$cropped || !file_exists($destPath)) {
$errDescription = "Crop failed";
return false;
}
return $destPath;
} catch (Exception $ex) {
$errDescription = $ex->getMessage();
return false;
}
}
示例2: generateThumbnail
private static function generateThumbnail(asset $srcAsset, thumbParamsOutput $destThumbParamsOutput, &$errDescription, $rotate = null)
{
$srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
if (!$fileSync || $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
$errDescription = 'Source asset could has no valid file sync';
return false;
}
$srcPath = $fileSync->getFullPath();
$uniqid = uniqid('thumb_');
$tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
if (!file_exists($tempDir)) {
mkdir($tempDir, 0700, true);
}
$destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . '.jpg';
$logPath = $destPath . '.log';
if (!file_exists($srcPath)) {
$errDescription = "Source file [{$srcPath}] does not exist";
return false;
}
if (!is_file($srcPath)) {
$errDescription = "Source file [{$srcPath}] is not a file";
return false;
}
try {
if ($srcAsset->getType() == assetType::FLAVOR) {
/* @var $srcAsset flavorAsset */
$dar = null;
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId());
if ($mediaInfo) {
$dar = $mediaInfo->getVideoDar();
}
// generates the thumbnail
$thumbMaker = new KFFMpegThumbnailMaker($srcPath, $destPath, kConf::get('bin_path_ffmpeg'));
$created = $thumbMaker->createThumnail($destThumbParamsOutput->getVideoOffset(), $srcAsset->getWidth(), $srcAsset->getHeight(), null, null, $dar);
if (!$created || !file_exists($destPath)) {
$errDescription = "Thumbnail not captured";
return false;
}
$srcPath = $destPath;
$uniqid = uniqid('thumb_');
$tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
if (!file_exists($tempDir)) {
mkdir($tempDir, 0700, true);
}
$destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . '.jpg';
}
if ($srcAsset->getType() == assetType::THUMBNAIL) {
$tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
if (!file_exists($tempDir)) {
mkdir($tempDir, 0700, true);
}
$destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . "." . $srcAsset->getFileExt();
}
$quality = $destThumbParamsOutput->getQuality();
$cropType = $destThumbParamsOutput->getCropType();
$cropX = $destThumbParamsOutput->getCropX();
$cropY = $destThumbParamsOutput->getCropY();
$cropWidth = $destThumbParamsOutput->getCropWidth();
$cropHeight = $destThumbParamsOutput->getCropHeight();
$bgcolor = $destThumbParamsOutput->getBackgroundColor();
$width = $destThumbParamsOutput->getWidth();
$height = $destThumbParamsOutput->getHeight();
$scaleWidth = $destThumbParamsOutput->getScaleWidth();
$scaleHeight = $destThumbParamsOutput->getScaleHeight();
$density = $destThumbParamsOutput->getDensity();
$stripProfiles = $destThumbParamsOutput->getStripProfiles();
$cropper = new KImageMagickCropper($srcPath, $destPath, kConf::get('bin_path_imagemagick'), true);
$cropped = $cropper->crop($quality, $cropType, $width, $height, $cropX, $cropY, $cropWidth, $cropHeight, $scaleWidth, $scaleHeight, $bgcolor, $density, $rotate, $stripProfiles);
if (!$cropped || !file_exists($destPath)) {
$errDescription = "Crop failed";
return false;
}
return $destPath;
} catch (Exception $ex) {
$errDescription = $ex->getMessage();
return false;
}
}