function createThumb($iTSize, $bSquare = true, $bForce = false, $strThumbPath = false) { if (!$strThumbPath) { $objThumb = new PImage(CACHE_DIR . "thumbnails/" . $iTSize . "x" . $iTSize . "/" . $this->getRelativePath()); } else { $objThumb = new PImage($strThumbPath); } //if objThumb exists if (is_file($objThumb->path)) { if (!$bForce) { return $objThumb; } else { if (!$objThumb->Delete()) { return false; } } } //create the directory $oDirParent = new PDir($objThumb->getParentPath()); if (!is_dir($oDirParent->path) && !$oDirParent->mkdir()) { return false; } if (!$this->Copy($this->getName(), $oDirParent->path)) { return false; } if (!$objThumb->ResizeMax($iTSize, $bSquare)) { $objThumb->Delete(); //if error occured while resizing thumb, delete it. return false; } return $objThumb; }
function resizeimage() { require SITE_PATH . 'core/lib/pimage.php'; if (!isset($_POST['FILE_RELATIVE_PATH'])) { return setError('Internal error in resize image, FILE_RELATIVE_PATH is not set'); } if (!isset($_POST['NEW_SIZE'])) { return setError('Internal error in resize image, NEW_SIZE is not set'); } $iNewSize = intval($_POST['NEW_SIZE']); if ($iNewSize < 100 || $iNewSize > 2048) { return setError(_('Size value is not valid.')); } $oImage = new PImage(SITE_PATH . urljsdecode($_POST['FILE_RELATIVE_PATH'])); if (!is_file($oImage->path)) { return setError('Internal error in resize image, object image not found.'); } if (!$oImage->is_image()) { return setError('The file is not an image'); } if (!$oImage->ResizeMax($iNewSize)) { return false; } return true; }