本文整理汇总了PHP中phpthumb_functions::EnsureDirectoryExists方法的典型用法代码示例。如果您正苦于以下问题:PHP phpthumb_functions::EnsureDirectoryExists方法的具体用法?PHP phpthumb_functions::EnsureDirectoryExists怎么用?PHP phpthumb_functions::EnsureDirectoryExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpthumb_functions
的用法示例。
在下文中一共展示了phpthumb_functions::EnsureDirectoryExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cache
/**
* Cache the generated thumbnail.
*/
public function cache()
{
phpthumb_functions::EnsureDirectoryExists(dirname($this->cache_filename));
if (file_exists($this->cache_filename) && is_writable($this->cache_filename) || is_writable(dirname($this->cache_filename))) {
$this->CleanUpCacheDirectory();
if ($this->RenderToFile($this->cache_filename) && is_readable($this->cache_filename)) {
chmod($this->cache_filename, 0644);
$this->RedirectToCachedFile();
}
}
}
示例2: dump
public function dump($preConf)
{
$imgDirecoryPrefix = $this->getTrackId() ? APP_ROOT : \Slim\Slim::getInstance()->config['mpd']['musicdir'];
$phpThumb = self::getPhpThumb();
$phpThumb->setSourceFilename($imgDirecoryPrefix . $this->getRelativePath());
$phpThumb->setParameter('config_output_format', 'jpg');
switch ($preConf) {
case 50:
case 100:
case 300:
case 1000:
$phpThumb->setParameter('w', $preConf);
break;
default:
$phpThumb->setParameter('w', 300);
}
$phpThumb->SetCacheFilename();
// check if we already have a cached image
if (is_file($phpThumb->cache_filename) === FALSE || is_readable($phpThumb->cache_filename) === FALSE) {
$phpThumb->GenerateThumbnail();
\phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename));
$phpThumb->RenderToFile($phpThumb->cache_filename);
if (is_file($phpThumb->cache_filename) === TRUE) {
chmod($phpThumb->cache_filename, 0777);
} else {
// something went wrong
// TODO: how to handle this?
// TODO: make sure we have no infinite loop...
return self::getFallbackImage()->dump($preConf);
}
}
#\Slim\Slim::getInstance()->response()->headers->set('Content-Type', 'image/jpeg');
header('Content-Type: image/jpeg');
readfile($phpThumb->cache_filename);
exit;
}
示例3: header
$phpThumb->DebugTimingMessage('phpThumbDebug[8]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '8') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if ($phpThumb->config_allow_parameter_file && $phpThumb->file) {
$phpThumb->RenderToFile($phpThumb->ResolveFilenameToAbsolute($phpThumb->file));
if ($phpThumb->config_allow_parameter_goto && $phpThumb->goto && preg_match('/^(f|ht)tps?\\:\\/\\//i', $phpThumb->goto)) {
// redirect to another URL after image has been rendered to file
header('Location: ' . $phpThumb->goto);
exit;
}
} elseif (@$PHPTHUMB_CONFIG['high_security_enabled'] && @$_GET['nocache']) {
// cache disabled, don't write cachefile
} else {
phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename));
if (@file_exists($phpThumb->cache_filename) && is_writable($phpThumb->cache_filename) || is_writable(dirname($phpThumb->cache_filename))) {
$phpThumb->CleanUpCacheDirectory();
if ($phpThumb->RenderToFile($phpThumb->cache_filename) && is_readable($phpThumb->cache_filename)) {
chmod($phpThumb->cache_filename, 0644);
RedirectToCachedFile();
} else {
$phpThumb->DebugMessage('Failed: RenderToFile(' . $phpThumb->cache_filename . ')', __FILE__, __LINE__);
}
} else {
$phpThumb->DebugMessage('Cannot write to $phpThumb->cache_filename (' . $phpThumb->cache_filename . ') because that directory (' . dirname($phpThumb->cache_filename) . ') is not writable', __FILE__, __LINE__);
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[9]', __FILE__, __LINE__);
示例4: scanMusicFileTags
public function scanMusicFileTags()
{
# TODO: handle orphaned records
# TODO: displaying itemsChecked / itemsProcessed is incorrect
# TODO: which speed-calculation makes sense? itemsChecked/minutute or itemsProcessed/minute or both?
$this->jobPhase = 2;
$this->beginJob(array('msg' => 'collecting tracks to scan from mysql database'), __FUNCTION__);
$app = \Slim\Slim::getInstance();
$phpThumb = Bitmap::getPhpThumb();
$phpThumb->setParameter('config_cache_directory', APP_ROOT . 'embedded');
$getID3 = new \getID3();
// make sure that a single directory will not be scanned twice
$scannedDirectories = array();
// get timestamps of all images from mysql database
$imageTimestampsMysql = array();
////////////////////////////////////////////////////////////////
// TEMP reset database status for testing purposes
#$query = "UPDATE rawtagdata SET importStatus=1, lastScan=0;";
#$app->db->query($query);
#$query = "DELETE FROM bitmap WHERE trackId > 0;";
#$app->db->query($query);
////////////////////////////////////////////////////////////////
if ($app->config['images']['look_cover_directory'] == TRUE) {
$this->pluralizeCommonArtworkDirectoryNames($app->config['images']['common_artwork_dir_names']);
}
$query = "\n\t\t\tSELECT COUNT(*) AS itemCountTotal\n\t\t\tFROM rawtagdata WHERE lastScan < filemtime";
$this->itemCountTotal = (int) $app->db->query($query)->fetch_assoc()['itemCountTotal'];
$query = "\n\t\t\tSELECT id,\n\t\t\t\trelativePath, relativePathHash, filemtime,\n\t\t\t\trelativeDirectoryPath, relativeDirectoryPathHash, directoryMtime \n\t\t\tFROM rawtagdata \n\t\t\tWHERE lastScan < filemtime";
// LIMIT 200000,1000;";
$result = $app->db->query($query);
$extractedImages = 0;
while ($record = $result->fetch_assoc()) {
$this->itemCountChecked++;
cliLog($record['id'] . ' ' . $record['relativePath'], 2);
$this->updateJob(array('msg' => 'processed ' . $this->itemCountChecked . ' files', 'currentItem' => $record['relativePath'], 'extractedImages' => $extractedImages));
$t = new Rawtagdata();
$t->setId($record['id']);
$t->setLastScan(time());
$t->setImportStatus(2);
// TODO: handle not found files
if (is_file($app->config['mpd']['musicdir'] . $record['relativePath']) === TRUE) {
$t->setFilesize(filesize($app->config['mpd']['musicdir'] . $record['relativePath']));
} else {
$t->setError('invalid file');
$t->update();
continue;
}
// skip very large files
// TODO: how to handle this?
if ($t->getFilesize() > 1000000000) {
$t->setError('invalid filesize ' . $t->getFilesize() . ' bytes');
$t->update();
continue;
}
$tagData = $getID3->analyze($app->config['mpd']['musicdir'] . $record['relativePath']);
\getid3_lib::CopyTagsToComments($tagData);
$this->mapTagsToRawtagdataInstance($t, $tagData);
$t->update();
if (!$app->config['images']['read_embedded']) {
continue;
}
if (isset($tagData['comments']['picture']) === FALSE) {
continue;
}
if (is_array($tagData['comments']['picture']) === FALSE) {
continue;
}
// loop through all embedded images
foreach ($tagData['comments']['picture'] as $bitmapIndex => $bitmapData) {
if (isset($bitmapData['image_mime']) === FALSE) {
// skip unspecifyable datachunk
continue;
}
if (isset($bitmapData['data']) === FALSE) {
// skip missing datachunk
continue;
}
$rawImageData = $bitmapData['data'];
if (strlen($rawImageData) < 20) {
// skip obviously invalid imagedata
continue;
}
if (strlen($rawImageData) > 40000) {
// skip huge imagedata
// got errormessage "Maximum supported image dimension is 65500 pixels" from ???
continue;
}
# TODO: delete tmp files of php thumb - shouldn't phpThumb handle that itself?
$phpThumb->resetObject();
$phpThumb->setSourceData($rawImageData);
$phpThumb->setParameter('config_cache_prefix', $record['relativePathHash'] . '_' . $bitmapIndex . '_');
$phpThumb->SetCacheFilename();
$phpThumb->GenerateThumbnail();
\phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename));
$phpThumb->RenderToFile($phpThumb->cache_filename);
$extractedImages++;
if (is_file($phpThumb->cache_filename) === FALSE) {
// there had been an error
// TODO: how to handle this?
continue;
//.........这里部分代码省略.........
示例5: generatePeakFile
private function generatePeakFile()
{
// extract peaks
$peakValues = $this->getPeaks();
// shorten values to configured limit
$peakValues = $this->limitArray($peakValues, $this->peakFileResolution);
\phpthumb_functions::EnsureDirectoryExists(dirname($this->peakValuesFilePath));
file_put_contents($this->peakValuesFilePath, join("\n", $peakValues));
return;
}