Example #1
0
 private function createThumbnailOfImage($imageName, $profilePic = false)
 {
     static $objImage, $arrSettings;
     if (empty($objImage)) {
         $objImage = new \ImageManager();
     }
     if (empty($arrSettings)) {
         $arrSettings = \User_Setting::getSettings();
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if ($profilePic) {
         if (!$objImage->loadImage($cx->getWebsiteImagesAccessProfilePath() . '/' . $imageName)) {
             return false;
         }
         $rationWidth = $objImage->orgImageWidth / $arrSettings['profile_thumbnail_pic_width']['value'];
         $rationHeight = $objImage->orgImageHeight / $arrSettings['profile_thumbnail_pic_height']['value'];
         if ($arrSettings['profile_thumbnail_method']['value'] == 'crop') {
             if ($rationWidth < $rationHeight) {
                 $objImage->orgImageHeight = $objImage->orgImageHeight / $rationHeight * $rationWidth;
             } else {
                 $objImage->orgImageWidth = $objImage->orgImageWidth / $rationWidth * $rationHeight;
             }
             if (!$objImage->resizeImage($arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value'], 70)) {
                 return false;
             }
         } else {
             $ration = max($rationWidth, $rationHeight);
             $objImage->addBackgroundLayer(sscanf($arrSettings['profile_thumbnail_scale_color']['value'], '#%2X%2x%2x'), $arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value']);
         }
         $thumb_name = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesAccessProfilePath() . '/' . $imageName);
         return $objImage->saveNewImage($thumb_name, true);
     } else {
         $thumb_name = \ImageManager::getThumbnailFilename($imageName);
         return $objImage->_createThumbWhq($cx->getWebsiteImagesAccessPhotoPath() . '/', $cx->getWebsiteImagesAccessPhotoWebPath() . '/', $imageName, $arrSettings['max_thumbnail_pic_width']['value'], $arrSettings['max_thumbnail_pic_height']['value'], 70, '', $cx->getWebsiteImagesAccessPhotoPath() . '/', $cx->getWebsiteImagesAccessPhotoWebPath() . '/', basename($cx->getWebsiteImagesAccessProfilePath() . '/' . $thumb_name));
     }
 }
Example #2
0
 private function createThumbnailOfImage($imageName, $profilePic = false)
 {
     static $objImage, $arrSettings;
     if (empty($objImage)) {
         $objImage = new \ImageManager();
     }
     if (empty($arrSettings)) {
         $arrSettings = \User_Setting::getSettings();
     }
     if ($profilePic) {
         if (!$objImage->loadImage(ASCMS_ACCESS_PROFILE_IMG_PATH . '/' . $imageName)) {
             return false;
         }
         $rationWidth = $objImage->orgImageWidth / $arrSettings['profile_thumbnail_pic_width']['value'];
         $rationHeight = $objImage->orgImageHeight / $arrSettings['profile_thumbnail_pic_height']['value'];
         if ($arrSettings['profile_thumbnail_method']['value'] == 'crop') {
             if ($rationWidth < $rationHeight) {
                 $objImage->orgImageHeight = $objImage->orgImageHeight / $rationHeight * $rationWidth;
             } else {
                 $objImage->orgImageWidth = $objImage->orgImageWidth / $rationWidth * $rationHeight;
             }
             if (!$objImage->resizeImage($arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value'], 70)) {
                 return false;
             }
         } else {
             $ration = max($rationWidth, $rationHeight);
             $objImage->addBackgroundLayer(sscanf($arrSettings['profile_thumbnail_scale_color']['value'], '#%2X%2x%2x'), $arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value']);
         }
         $thumb_name = \ImageManager::getThumbnailFilename($imageName);
         return $objImage->saveNewImage(ASCMS_ACCESS_PROFILE_IMG_PATH . '/' . $thumb_name);
     } else {
         return $objImage->_createThumbWhq(ASCMS_ACCESS_PHOTO_IMG_PATH . '/', ASCMS_ACCESS_PHOTO_IMG_WEB_PATH . '/', $imageName, $arrSettings['max_thumbnail_pic_width']['value'], $arrSettings['max_thumbnail_pic_height']['value'], 70);
     }
 }