Example #1
0
     $tsuff = $params->get('thumbsuffix') . '/';
     $foldercheck = 'images/stories/mod_aidanews_thumbs/' . $tsuff;
     if (!is_dir($foldercheck)) {
         mkdir($foldercheck);
     }
 } else {
     $tsuff = '';
 }
 $last = strrpos($image, "/");
 $name = substr($image, $last + 1);
 $ext = strrchr($name, '.');
 $thumb = substr($name, 0, -strlen($ext));
 $newtb = "images/stories/mod_aidanews_thumbs/" . $tsuff . $thumb . ".jpg";
 if (file_exists($newtb)) {
 } else {
     $tb = new ThumbAndCrop();
     $tb->openImg($image);
     if ($imageHeight && empty($imageWidth)) {
         $newWidth = $tb->getRightWidth($imageHeight);
         $tb->creaThumb($newWidth, $imageHeight);
     } elseif (empty($imageHeight) && $imageWidth) {
         $newHeight = $tb->getRightHeight($imageWidth);
         $tb->creaThumb($imageWidth, $newHeight);
     } elseif ($imageHeight && $imageWidth) {
         $newWidth = $tb->getRightWidth($imageHeight);
         $newHeight = $tb->getRightHeight($imageWidth);
         if ($newWidth > $imageWidth) {
             $subWidth = ($newWidth - $imageWidth) / 2;
             $tb->creaThumb($newWidth, $imageHeight);
             $tb->setThumbAsOriginal();
             $tb->cropThumb($imageWidth, $imageHeight, $subWidth, 0);
Example #2
0
File: c.php Project: neevan1e/Done
<?php

if (isset($_POST['pos'])) {
    $from_top = abs($_POST['pos']);
    $default_cover_width = 918;
    $default_cover_height = 276;
    // includo la classe
    require_once "thumbncrop.inc.php";
    //php class for image resizing & cropping
    // valorizzo la variabile
    $tb = new ThumbAndCrop();
    // apro l'immagine
    $tb->openImg("original.jpg");
    //original cover image
    $newHeight = $tb->getRightHeight($default_cover_width);
    $tb->creaThumb($default_cover_width, $newHeight);
    $tb->setThumbAsOriginal();
    $tb->cropThumb($default_cover_width, 276, 0, $from_top);
    $tb->saveThumb("cover.jpg");
    //save cropped cover image
    $tb->resetOriginal();
    $tb->closeImg();
    $data['status'] = 200;
    $data['url'] = 'cover.jpg';
    echo json_encode($data);
}