function createThumbnail($name) { $name = get_magic_quotes_gpc() ? stripslashes($name) : $name; $name = basename($name); $folderName = KT_RealPath($this->config['photo_folder'], true); $fullFileName = $folderName . $name; $folderName = KT_RealPath($this->config['photo_folder'], true); $thumb_path = $folderName . $GLOBALS['GAL_thumbnail_folder']; $info = KT_pathinfo($fullFileName); $fullThumbnailName = $info['filename'] . '_' . $this->config['thumbnails']['width'] . 'x' . $this->config['thumbnails']['height'] . '.' . $info['extension']; $image = new KT_image(); $imageLib = ''; if (isset($GLOBALS['KT_prefered_image_lib'])) { $imageLib = $GLOBALS['KT_prefered_image_lib']; $image->setPreferedLib($imageLib); } if ($imageLib == 'imagemagick') { if (isset($_SESSION['Widgets.Gallery']['config']['ExecPath'])) { $image->addCommand($_SESSION['Widgets.Gallery']['config']['ExecPath']); } else { if (isset($GLOBALS['KT_prefered_imagemagick_path'])) { $image->addCommand($GLOBALS['KT_prefered_imagemagick_path']); } } } $image->thumbnail($fullFileName, $thumb_path, $fullThumbnailName, $this->config['thumbnails']['width'], $this->config['thumbnails']['height'], true); $toret = array(); if ($image->hasError()) { $errors = $image->getError(); $errorLevel = !empty($GLOBALS['tNG_debug_mode']) ? $GLOBALS['tNG_debug_mode'] == 'PRODUCTION' ? 0 : 1 : 1; $toret = array('error' => $errors[$errorLevel]); } else { $execPath = $image->getImageMagickPath(); if (!isset($_SESSION['Widgets.Gallery']['config']['ExecPath'])) { $_SESSION['Widgets.Gallery']['config']['ExecPath'] = $execPath; } $thumbSizeArr = getimagesize($folderName . $GLOBALS['GAL_thumbnail_folder'] . $fullThumbnailName); $toret['thumbnail'] = array('name' => $GLOBALS['GAL_thumbnail_folder'] . $fullThumbnailName, 'width' => $thumbSizeArr[0], 'height' => $thumbSizeArr[1]); } return $toret; }