function resizeWithGD($image, $group_id, $type, $watermark = true) { if (!file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'])) { mkdir(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'], 0777); } $original_image = DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[1]['code'] . '/' . $image; $dest_image = DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'] . '/' . $image; if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[1]['code'] . '/' . $image)) { //watermark if ($watermark == true) { if (defined('WATERMARK_FILE_NAME') && @file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . WATERMARK_FILE_NAME)) { $opacity_name = strtoupper('WATERMARK_' . $type . '_' . $group_id . '_OPACITY'); $position_name = strtoupper('WATERMARK_' . $type . '_' . $group_id . '_POSITION'); if (defined($opacity_name) && defined($position_name)) { $original_watermarked_image = DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[1]['code'] . '/' . 'watermark_' . $image; if (!file_exists($original_watermarked_image)) { toc_draw_watermark($original_image, $original_watermarked_image, DIR_FS_CATALOG . DIR_WS_IMAGES . WATERMARK_FILE_NAME, constant($position_name), constant($opacity_name)); } $original_image = $original_watermarked_image; } } } return osc_gd_resize($original_image, $dest_image, $this->_groups[$group_id]['size_width'], $this->_groups[$group_id]['size_height'], $this->_groups[$group_id]['force_size'] == '1'); } }
function resizeWithGD($image, $group_id, $type) { if (!file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'])) { mkdir(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'], 0777); } if (file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[1]['code'] . '/' . $image)) { return osc_gd_resize(DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[1]['code'] . '/' . $image, DIR_FS_CATALOG . DIR_WS_IMAGES . $type . '/' . $this->_groups[$group_id]['code'] . '/' . $image, $this->_groups[$group_id]['size_width'], $this->_groups[$group_id]['size_height'], $this->_groups[$group_id]['force_size'] == '1'); } }
function upload() { $logo_image = new upload('logo_image'); if ($logo_image->exists()) { self::deleteLogo('originals'); $img_type = substr($_FILES['logo_image']['name'], strrpos($_FILES['logo_image']['name'], '.') + 1); $original = DIR_FS_CATALOG . DIR_WS_IMAGES . 'logo_originals.' . $img_type; $logo_image->set_destination(realpath(DIR_FS_CATALOG . 'images/')); if ($logo_image->parse() && $logo_image->save()) { copy(DIR_FS_CATALOG . 'images/' . $logo_image->filename, $original); @unlink(DIR_FS_CATALOG . 'images/' . $logo_image->filename); $osC_DirectoryListing = new osC_DirectoryListing('../templates'); $osC_DirectoryListing->setIncludeDirectories(true); $osC_DirectoryListing->setIncludeFiles(false); $osC_DirectoryListing->setExcludeEntries('system'); $templates = $osC_DirectoryListing->getFiles(); foreach ($templates as $template) { $code = $template['name']; if (file_exists('../templates/' . $code . '/template.php')) { include '../templates/' . $code . '/template.php'; $class = 'osC_Template_' . $code; self::deleteLogo($code); if (class_exists($class)) { $module = new $class(); $logo_height = $module->getLogoHeight(); $logo_width = $module->getLogoWidth(); $dest_image = DIR_FS_CATALOG . DIR_WS_IMAGES . 'logo_' . $code . '.' . $img_type; osc_gd_resize($original, $dest_image, $logo_width, $logo_height); } } } return true; } } return false; }
function resizeLogo() { $osC_DirectoryListing = new osC_DirectoryListing('../images'); $osC_DirectoryListing->setIncludeDirectories(false); $files = $osC_DirectoryListing->getFiles(true); foreach ($files as $file) { $filename = explode(".", $file['name']); if ($filename[0] == 'logo_originals') { $img_type = $filename[sizeof($filename) - 1]; $original_image = DIR_FS_CATALOG . DIR_WS_IMAGES . $file['name']; $dest_image = DIR_FS_CATALOG . DIR_WS_IMAGES . 'logo_' . $this->getCode() . '.' . $img_type; osc_gd_resize($original_image, $dest_image, $this->getLogoWidth(), $this->getLogoHeight()); } } }