Example #1
0
$IV = array('GET' => array('f' => array('filename'), 'm' => array('string', 'default' => null)));
require ROOT . '/library/preprocessor.php';
$imagePath = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$_GET['f']}";
if ($fp = @fopen($imagePath, 'r')) {
    if (isset($_GET['m']) && !empty($_GET['m'])) {
        if (file_exists($imagePath)) {
            $imageInfo = getimagesize($imagePath);
            $cropSize = $_GET['m'];
            $objThumbnail = new Utils_Image();
            if ($imageInfo[0] > $imageInfo[1]) {
                list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize);
            } else {
                list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null);
            }
            $objThumbnail->imageFile = $imagePath;
            if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) {
                $objThumbnail->saveAsCache();
            }
            unset($objThumbnail);
        }
    } else {
        $imageInfo = @getimagesize($imagePath);
        if (function_exists('gd_info')) {
            switch ($imageInfo[2]) {
                case 1:
                    $image = imagecreatefromgif($imagePath);
                    break;
                case 2:
                    $image = imagecreatefromjpeg($imagePath);
                    break;
                case 3:
Example #2
0
function printIphoneCropProcess($blogid, $filename, $cropSize)
{
    global $serviceURL;
    $tempFile = null;
    $imageURL = null;
    if (stristr($filename, 'http://')) {
        list($originSrc, $filename, $tempFile) = printIphoneCreateRemoteImage($blogid, $filename);
    } else {
        $originSrc = ROOT . "/attach/{$blogid}/{$filename}";
    }
    $thumbnailSrc = ROOT . "/cache/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}";
    if (file_exists($originSrc)) {
        $imageInfo = getimagesize($originSrc);
        $objThumbnail = new Utils_Image();
        if ($imageInfo[0] > $imageInfo[1]) {
            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize);
        } else {
            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null);
        }
        $objThumbnail->imageFile = $originSrc;
        if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) {
            $imageURL = "{$serviceURL}/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}";
            $objThumbnail->saveAsFile($thumbnailSrc);
        }
        unset($objThumbnail);
        if ($tempFile) {
            unlink($originSrc);
        }
    } else {
        $imageURL = null;
    }
    return $imageURL;
}
Example #3
0
function MT_Cover_getCropProcess($blogid, $filename, $cropSize)
{
    $context = Model_Context::getInstance();
    $tempFile = null;
    $imageURL = null;
    if (stristr($filename, 'http://')) {
        list($originSrc, $filename, $tempFile) = MT_Cover_getCreateRemoteImage($blogid, $filename);
    } else {
        $originSrc = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$filename}";
    }
    $thumbnailSrc = __TEXTCUBE_CACHE_DIR__ . "/thumbnail/{$blogid}/coverPostThumbnail/th_{$filename}";
    if (file_exists($originSrc)) {
        $imageInfo = getimagesize($originSrc);
        $objThumbnail = new Utils_Image();
        if ($imageInfo[0] > $imageInfo[1]) {
            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize);
        } else {
            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $cropSize, null);
        }
        $objThumbnail->imageFile = $originSrc;
        if ($objThumbnail->resample($tempWidth, $tempHeight) && $objThumbnail->cropRectBySize($cropSize, $cropSize)) {
            $imageURL = $context->getProperty('uri.service') . "/thumbnail/{$blogid}/coverPostThumbnail/th_{$filename}";
            $objThumbnail->saveAsFile($thumbnailSrc);
        }
        unset($objThumbnail);
        if ($tempFile) {
            unlink($originSrc);
        }
    } else {
        $imageURL = null;
    }
    return $imageURL;
}