当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleImage::square_crop方法代码示例

本文整理汇总了PHP中SimpleImage::square_crop方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::square_crop方法的具体用法?PHP SimpleImage::square_crop怎么用?PHP SimpleImage::square_crop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleImage的用法示例。


在下文中一共展示了SimpleImage::square_crop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addMonial

 function addMonial()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.utilities.utility');
     JRequest::checkToken() or jexit('Invalid Token');
     $app = JFactory::getApplication();
     $db =& JFactory::getDBO();
     $document =& JFactory::getDocument();
     require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'SimpleImage.php';
     $myparams =& JComponentHelper::getParams('com_eztestimonial');
     $imageSubFolder = $myparams->getValue('data.params.imagefolder');
     $autoApprove = $myparams->getValue('data.params.autoapprove', 0);
     $uploadSize = $myparams->getValue('data.params.imagesize', 400);
     $spamfilter = $myparams->getValue('data.params.spamfilter');
     $sendemailtouser = $myparams->getValue('data.params.sendemailtouser', 0);
     $sendemailtoadmin = $myparams->getValue('data.params.sendemailtoadmin', 0);
     $summerytxtlength = $myparams->getValue('data.params.summerytxtlength', 100);
     $ImgUrl = JRoute::_(JURI::base() . 'images/' . $imageSubFolder . '/');
     $returnUrl = JRoute::_("index.php?option=com_eztestimonial&view=testimonials");
     $valid = true;
     $fullname = strip_tags(JRequest::getVar('iname'));
     $useremail = strip_tags(JRequest::getVar('iemail'));
     $location = strip_tags(JRequest::getVar('iaddress'));
     $website = strip_tags(JRequest::getVar('iwebsite'));
     $message = strip_tags(JRequest::getVar('imessage'));
     $aboutme = strip_tags(JRequest::getVar('iboutme'));
     $rating = JRequest::getVar('rating');
     $file = JRequest::getVar('iimage', null, 'files', 'array');
     $filename = JFile::makeSafe($file['name']);
     $src = $file['tmp_name'];
     $extension_of_image = testimonialController::get_extension(strtolower($filename));
     //get the extension of image
     $FileSize = filesize($file['tmp_name']);
     $AllowedSize = $uploadSize * 1048576;
     if ($spamfilter == 1) {
         $privatekey = $myparams->getValue('data.params.reprivatekey');
         require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'recaptchalib.php';
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         if (!$resp->is_valid) {
             $app->enqueueMessage(JText::_('COM_TESTIMONIALS_WRONGRECAPTCHA'), 'error');
             $valid = false;
         }
     } elseif ($spamfilter == 2) {
         $akismetKey = $myparams->getValue('data.params.akismetKey');
         require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'Akismet.class.php';
         $MyURL = JURI::base();
         $akismet = new Akismet($MyURL, $akismetKey);
         $akismet->setCommentAuthor($fullname);
         $akismet->setCommentAuthorEmail($email);
         $akismet->setCommentAuthorURL($website);
         $akismet->setCommentContent($message);
         $akismet->setPermalink(JURI::current());
         if ($akismet->isCommentSpam()) {
             die("spam alert!");
             $valid = false;
         }
     }
     if ($FileSize > $AllowedSize) {
         $exceededtxt = JText::sprintf(JText::_('COM_TESTIMONIALS_IMAGESIZETOOBIG'), testimonialController::format_bytes($AllowedSize), testimonialController::format_bytes($FileSize));
         $app->enqueueMessage($exceededtxt, 'error');
         $valid = false;
     }
     if (strlen($FileSize) <= 1 && strlen($filename) > 1) {
         $app->enqueueMessage(JText::_('COM_TESTIMONIALS_ERRUPLOADING'), 'error');
         $valid = false;
     }
     if ($FileSize > 1 && $valid == true) {
         // Import image
         switch ($extension_of_image) {
             case 'jpg':
             case 'jpeg':
             case 'png':
             case 'gif':
                 break;
             default:
                 // Unsupported format
                 $app->enqueueMessage(JText::_('COM_TESTIMONIALS_FILENOTSUPPORTED'), 'error');
                 $valid = false;
                 break;
         }
     }
     if ($FileSize > 1 && $valid == true) {
         $random_str = testimonialController::random_str();
         $photo_name = strtolower(str_replace(" ", "-", htmlspecialchars($fullname))) . "-" . $random_str . ".";
         // cleaned photo name with random charactor
         $newPhotoname = $photo_name . $extension_of_image;
         $newPhotoPath = JPATH_BASE . DS . "images" . DS . $imageSubFolder . DS;
         $thumb_dest = $newPhotoPath . 'thumb_' . $newPhotoname;
         $thumb_dest50 = $newPhotoPath . 'thumb50_' . $newPhotoname;
         $dest = $newPhotoPath . $newPhotoname;
         $image = new SimpleImage();
         $image->square_crop($file['tmp_name'], $thumb_dest, $thumb_size = 200, $jpg_quality = 90);
         $image->square_crop($file['tmp_name'], $thumb_dest50, $thumb_size = 50, $jpg_quality = 90);
         $image->load($file['tmp_name']);
         //$image->resizeToWidth(600);
         $image->save($dest);
     } else {
         $newPhotoname = '';
     }
     if (strlen($fullname) < 2) {
//.........这里部分代码省略.........
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:101,代码来源:controller.php

示例2: moveTradeTmpImages

/**
 * Move temp images from temp directory.
 *
 * @param mixed $image
 */
function moveTradeTmpImages($images)
{
    $imageList = explode('|', $images);
    $tmpStrPath = str_replace(DIR_FS_TRADE_IMG, '/', DIR_FS_TRADE_IMG_TMP);
    $userID = buckys_is_logged_in();
    if (count($imageList) > 0 && $userID) {
        $rootPath = rtrim(DIR_FS_ROOT, '/');
        if (!is_dir(DIR_FS_TRADE_IMG . $userID)) {
            $createSuccessFlag = mkdir(DIR_FS_TRADE_IMG . $userID, 0777);
            //Create Index.html to prevent directory listing issue
            $fp = fopen(DIR_FS_TRADE_IMG . $userID . "/index.html", "w");
            fclose($fp);
            if ($createSuccessFlag === false) {
                return $createSuccessFlag;
            }
        }
        foreach ($imageList as $imgFile) {
            if (strpos($imgFile, $tmpStrPath) !== false) {
                $newFilePath = str_replace($tmpStrPath, '/' . $userID . '/', $imgFile);
                @copy($rootPath . $imgFile, $rootPath . $newFilePath);
                @unlink($rootPath . $imgFile);
                $thumbPathInfo = pathinfo($rootPath . $newFilePath);
                $thumbFileName = $thumbPathInfo['dirname'] . "/" . $thumbPathInfo['filename'] . TRADE_ITEM_IMAGE_THUMB_SUFFIX . "." . $thumbPathInfo['extension'];
                unset($resizeImageIns);
                $resizeImageIns = new SimpleImage($rootPath . $newFilePath);
                $resizeImageIns->square_crop(150);
                $resizeImageIns->save($thumbFileName);
            }
        }
        $images = str_replace($tmpStrPath, '/' . $userID . '/', $images);
        return $images;
    } else {
        return '';
    }
}
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:40,代码来源:process.php

示例3: SimpleImage

    $file = '';
}
if (empty($file) || !file_exists($root . $file)) {
    $file = '/noimage.jpg';
}
echo $file;
exit;
$fileRes = '/resize/' . $height . '/' . $width . '/' . $type . $file;
$file = $root . $file;
$fileRes = $root . $fileRes;
if (!file_exists($fileRes)) {
    require_once $root . '/SimpleImage.php';
    $simpleImage = new SimpleImage();
    $simpleImage->load($file);
    switch ($type) {
        case 'no':
            $simpleImage->square_crop($height, $width);
            break;
        case 'w':
            $simpleImage->fit_to_width($width);
            break;
        case 'h':
            $simpleImage->fit_to_height($height);
            break;
        case 's':
            $simpleImage->resize($height, $width);
            break;
    }
    createFolders($fileRes);
    $simpleImage->save($fileRes);
}
开发者ID:roman1970,项目名称:lis,代码行数:31,代码来源:resize.php


注:本文中的SimpleImage::square_crop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。