Your IP : 216.73.216.240
<?php
/**
* @package mod_artsexylightbox_lite - Art Sexy Lightbox Lite
* @author Artetics.com
* @license GNU GPL v2 or later
* @copyright Artetics.com (c) 2017
* @version 1.9.2
**/
defined("_JEXEC") or die("Restricted access");
function generateThumbnail($imagePath,$convertImage,$previewWidth,$previewHeight,$cropStart,$watermark,$watermarkPosition){
$imagePathInfo = pathinfo($imagePath);
if ($watermark && $convertImage) {
$generatedThumbName = sprintf('%s_%s_%s.%s',
md5('artsexythumb_' . $convertImage . '_' . $imagePath . '_' . $watermark . $watermarkPosition),
$previewWidth,
$previewHeight ,
$imagePathInfo['extension']);
}
else if($watermark){
$generatedThumbName = sprintf('%s_%s_%s.%s',
md5('artsexythumb_' . $imagePath . '_' . $watermark . $watermarkPosition),
$previewWidth,
$previewHeight ,
$imagePathInfo['extension']);
}
else if($cropStart && $convertImage == "crop"){
$generatedThumbName = sprintf('%s_%s_%s.%s',
md5('artsexythumb_' . $convertImage . '_' . str_replace(",","",$cropStart) . '_' . $imagePath),
$previewWidth,
$previewHeight,
$imagePathInfo['extension']);
}
else{
$generatedThumbName = sprintf('%s_%s_%s.%s',
md5('artsexythumb_' . $convertImage . '_' . $imagePath),
$previewWidth,
$previewHeight,
$imagePathInfo['extension']);
}
if (!file_exists(JPATH_SITE . ASLDS . 'images' . ASLDS . 'artsexylightbox_tmp')) {
mkdir (JPATH_SITE . ASLDS . 'images' . ASLDS . 'artsexylightbox_tmp');
}
$thumbPath = JPATH_SITE . ASLDS . 'images' . ASLDS . 'artsexylightbox_tmp' . ASLDS . $generatedThumbName;
//if generated thumb doesn't already exist, make a new one
if (!@file_exists($thumbPath)) {
$img = asido::image($imagePath, $thumbPath);
if ($convertImage == 'crop' && $previewWidth && $previewHeight) {
//$cropStart is x,y coordinates in pixels?
if ($cropStart) {
$cropStartArray = explode(',', $cropStart);
Asido::crop($img, $cropStartArray[0], $cropStartArray[1], $previewWidth, $previewHeight);
} else {
Asido::crop($img, 0, 0, $previewWidth, $previewHeight);
}
}else if ($convertImage == 'crop_resize' && $previewWidth && $previewHeight) {
$imgSize = getimagesize($imagePath);
$imgWidth = $imgSize[0];
$imgHeight = $imgSize[1];
if ($imgWidth > $imgHeight) {
$diff = ($imgWidth - $imgHeight)/2;
Asido::crop($img, $diff, 0, ($imgWidth - 2*$diff), $imgHeight);
} else if ($imgWidth < $imgHeight) {
$diff = ($imgHeight - $imgWidth)/2;
Asido::crop($img, 0, $diff, $imgWidth, ($imgHeight - 2*$diff));
}
Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH);
}else if (strstr($convertImage, 'rotate')) {
$rotateAttrs = explode(':', $convertImage);
if (!$rotateAttrs[1]) {
$rotateAttrs[1] = 90;
}
Asido::rotate($img, $rotateAttrs[1]);
}else if ($convertImage == 'grayscale') {
Asido::greyScale($img);
}else {
if ($previewHeight && !$previewWidth) {
Asido::height($img, $previewHeight);
} else if ($previewWidth && !$previewHeight) {
Asido::width($img, $previewWidth);
} else if($previewHeight && $previewWidth){
Asido::resize($img, $previewWidth, $previewHeight, ASIDO_RESIZE_STRETCH);
}
}
if ($watermark) {
switch($watermarkPosition) {
case 'topleft':
Asido::watermark($img, JPATH_SITE . ASLDS . str_replace('/', ASLDS, $watermark), ASIDO_WATERMARK_TOP_LEFT);
break;
case 'topright':
Asido::watermark($img, JPATH_SITE . ASLDS . str_replace('/', ASLDS, $watermark), ASIDO_WATERMARK_TOP_RIGHT);
break;
case 'bottomleft':
Asido::watermark($img, JPATH_SITE . ASLDS . str_replace('/', ASLDS, $watermark), ASIDO_WATERMARK_BOTTOM_LEFT);
break;
case 'bottomright':
Asido::watermark($img, JPATH_SITE . ASLDS . str_replace('/', ASLDS, $watermark), ASIDO_WATERMARK_BOTTOM_RIGHT);
break;
default:
Asido::watermark($img, JPATH_SITE . ASLDS . str_replace('/', ASLDS, $watermark), ASIDO_WATERMARK_TOP_LEFT);
break;
}
}
$img->save(ASIDO_OVERWRITE_ENABLED);
}
$previewImagePath = JURI::root() . "images/artsexylightbox_tmp/$generatedThumbName";
return $previewImagePath;
}
?>