Example #1
0
function get_image($input, $image = null, $type = 'team', $scale = false) {
	$year = date('Y');
	$day = date('md');
	$n = time() . rand(1000, 9999) . '.jpg';

	RecursiveMkdir(IMG_ROOT . '/' . "{$type}/{$year}/{$day}");
	$image = "{$type}/{$year}/{$day}/{$n}";
	$path = IMG_ROOT . '/' . $image;
	if (!grabImage($input, $path)){
		return false;
	}
	
	if ($type == 'team' && $scale) {
		$npath = preg_replace('#(\d+)\.(\w+)$#', "\\1_index.\\2", $path);
		Image :: Convert($path, $npath, 200, 120, Image :: MODE_CUT);
	}
	return $image;
}
Example #2
0
function getFilePath($sImage)
{
    global $oS3Object, $sOutputDir, $sOption, $iWidth, $iHeight, $sExt, $sDestFile;
    $sLocalPath = substr($sImage, strpos($sImage, 'file/pic/'));
    $aFile = pathinfo($sImage);
    $sExt = $aFile['extension'];
    $sDestPath = $sOutputDir . $sDestFile;
    $sResourcePath = 'tmp' . PHPFOX_DS . md5($sImage) . '.' . $sExt;
    if (strpos($sImage, 'amazon')) {
        if (!file_exists($sResourcePath)) {
            $oS3Object->getObject(Phpfox::getParam('core.amazon_bucket'), $sLocalPath, $sResourcePath);
        }
        $sResourcePath = $sTmpImage;
    } elseif (is_numeric(strpos($sImage, Phpfox::getParam('core.path')))) {
        $sResourcePath = PHPFOX_DIR . $sLocalPath;
    } else {
        if (!file_exists($sResourcePath)) {
            grabImage($sImage, $sResourcePath);
        }
    }
    return array($sResourcePath, $sDestPath);
}
function grabImages($sInputFile, $sOutputFile, $iSecond = 0, $bForse = false, $aFilesConfig = array())
{
    if (!$aFilesConfig) {
        $aFilesConfig = BxDolService::call('videos', 'get_files_config');
    }
    $fRatio = 0;
    foreach ($aFilesConfig as $a) {
        if (!isset($a['image']) || !$a['image']) {
            continue;
        }
        $sResize = '';
        if ($fRatio && isset($a['square']) && $a['square'] && isset($a['w']) && $a['w'] && $fRatio < 1) {
            $sResize = "-vf crop=out_h=in_w -s {$a['w']}x{$a['w']}";
        } elseif ($fRatio && isset($a['square']) && $a['square'] && isset($a['w']) && $a['w']) {
            $sResize = "-vf crop=out_w=in_h -s {$a['w']}x{$a['w']}";
        } elseif (isset($a['w']) && isset($a['h']) && $a['w'] && $a['h']) {
            $sResize = "-s {$a['w']}x{$a['h']}";
        }
        if ($sInputFile != $sOutputFile . $a['postfix']) {
            @unlink($sOutputFile . $a['postfix']);
        }
        if (!grabImage($sInputFile, $sOutputFile . $a['postfix'], $sResize, $iSecond, $bForse)) {
            return false;
        }
        if (!$fRatio) {
            $aSize = getimagesize($sOutputFile . $a['postfix']);
            $fRatio = $aSize[0] / $aSize[1];
        }
    }
    return true;
}
Example #4
0
             //check if there needs to be tags
             if (in_category("breaking")) {
                 //echo '<!--Any tags it may have--><div class="' . tc_featured_tag . ' ' .tc_featured_breaking . '">Breaking</div>';
                 $tagName = "Breaking";
             } else {
                 if (in_category("exclusive")) {
                     //echo '<!--Any tags it may have--><div class="' . tc_featured_tag . ' ' . tc_featured_exclusive  . '">Exclusive</div>';
                     $tagName = "Exclusive";
                 } else {
                     if (in_category("exclusive") && in_category("featured")) {
                         //echo '<!--Any tags it may have--><div class="' . tc_featured_tag . ' ' . tc_featured_exclusive . '">Exclusive</div>';
                         $tagName = "Exclusive";
                     }
                 }
             }
             $image = grabImage(get_the_content(), $post->ID, "featured");
             $dataArray[$counter]["post" . $counter2]["side"] = $side;
             $dataArray[$counter]["post" . $counter2]["key"] = encrypt_key($post->post_modified);
             $dataArray[$counter]["post" . $counter2]["id"] = $post->ID;
             $dataArray[$counter]["post" . $counter2]["tagName"] = $tagName;
             $dataArray[$counter]["post" . $counter2]["image"] = $image;
             $dataArray[$counter]["post" . $counter2]["name"] = $post->post_name;
             $dataArray[$counter]["post" . $counter2]["title"] = neat_trim(get_the_title(), 40, "...");
             //add to the counter
             $counter2++;
             $tagName = "";
         }
         $dataArray[$counter]["catName"] = get_cat_name($featured_cat);
     }
     echo json_encode($dataArray);
 }
Example #5
0
function grabImages($sInputFile, $sOutputFile, $iSecond = 0, $bForse = false)
{
    $bResult = grabImage($sInputFile, $sOutputFile . IMAGE_EXTENSION, "", $iSecond, $bForse);
    if (!$bResult) {
        return false;
    }
    return grabImage($sInputFile, $sOutputFile . THUMB_FILE_NAME . IMAGE_EXTENSION, "-s " . THUMB_SIZE, $iSecond, $bForse);
}