$tb->setThumbAsOriginal(); $tb->cropThumb($imageWidth, $imageHeight, $subWidth, 0); } elseif ($newWidth == $imageWidth) { $tb->creaThumb($imageWidth, $imageHeight); } elseif ($newWidth < $imageWidth) { $subHeight = ($newHeight - $imageHeight) / 2; $tb->creaThumb($imageWidth, $newHeight); $tb->setThumbAsOriginal(); $tb->cropThumb($imageWidth, $imageHeight, 0, $subHeight); } } else { $orHeight = $tb->getHeight(); $orWidth = $tb->getWidth(); $tb->creaThumb($orWidth, $orHeight); } $tb->saveThumb($newtb, $params->get('quality')); $tb->closeImg(); } if ($params->get('use_tooltips')) { $image_url = '<img src="' . $newtb . '" alt="' . $row->title . '" border="0"' . '/>'; } else { $image_url = '<img src="' . $newtb . '" alt="' . $row->title . '" title="' . $row->title . '" border="0"' . '/>'; } } else { //Images - HTML Resize //Set up the width and height variables if ($imageWidth > 0) { $width = ' width="' . $imageWidth . 'px"'; } else { $width = ''; }
<?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); }