コード例 #1
0
ファイル: perfilAction.php プロジェクト: narbelys/fototea
     //        }
     //TODO validate image size
     $fileName = $type . '_temp.jpg';
     $filePath = $baseProfileDir . $fileName;
     $fileUrl = $baseProfileUrl . $fileName;
     //        $cropWidth = min(ceil($tmpImageWidth * 0.7), ceil($tmpImageHeight * 0.7));
     //        $cropHeight = ceil($cropWidth / $aspectRatio);
     //
     //        $x1Crop = 0;
     //        $y1Crop = 0;
     //        $x2Crop = $cropWidth;
     //        $y2Crop = $cropHeight;
     //75,336,775,528
     //Center it
     //Save as jpeg
     $resultSave = ImageHelper::saveImageAsJPG($file['tmp_name'], $file['type'], $filePath);
     //error_get_last()
     if ($resultSave) {
         $response->status = 'success';
         $response->img_url = FConfig::getUrl($fileUrl, true);
         $response->width = $tmpImageWidth;
         $response->height = $tmpImageHeight;
     } else {
         $response->status = 'error';
         $response->message = "crop image could not be created";
     }
     echo json_encode($response);
     die;
 }
 /**
  * Mark wizard completed to the current user after the first login in the site
コード例 #2
0
ファイル: thumb.php プロジェクト: narbelys/fototea
//Generate thumbnail name
$thumbFileName = str_replace("/", "_", $imageUrl);
$thumbInfo = pathinfo($thumbFileName);
$thumbFileName = $thumbInfo['filename'] . "." . $thumbExtension;
$width = intval($_GET['w']);
$height = intval($_GET['h']);
if ($height == 0) {
    echo 'stop here';
}
$cacheFolder = $basePath . 'profiles' . DS . 'cache' . DS . $width . "x" . $height . DS;
if ($_GET['refresh'] != 'true') {
    //USAR LA CACHE
    if (file_exists($cacheFolder . $thumbFileName)) {
        header('Content-Type: image/jpeg');
        echo file_get_contents($cacheFolder . $thumbFileName);
        exit;
    }
}
if (!file_exists($cacheFolder)) {
    $old = umask(0);
    mkdir($cacheFolder, 0777, true);
    umask($old);
}
$availableModes = array(ImageHelper::MODE_CROP_CENTER, ImageHelper::MODE_RESIZE);
$mode = ImageHelper::MODE_RESIZE;
if (in_array($_GET['mode'], $availableModes)) {
    $mode = $_GET['mode'];
}
ImageHelper::generateThumb($basePath . $imageUrl, $cacheFolder . $thumbFileName, $width, $height, $mode);
header('Content-Type: image/jpeg');
echo file_get_contents($cacheFolder . $thumbFileName);