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


PHP crop函数代码示例

本文整理汇总了PHP中crop函数的典型用法代码示例。如果您正苦于以下问题:PHP crop函数的具体用法?PHP crop怎么用?PHP crop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: insert

 function insert()
 {
     $newFileName = rand(9999999, 0) . $_FILES['site_logo']['name'];
     $config['upload_path'] = UPLOAD_PATH . 'admin_log';
     $config['allowed_types'] = 'gif|jpg|png';
     $config['file_name'] = $newFileName;
     $this->load->library('upload');
     $this->upload->initialize($config);
     $angle['x1']['0'] = $_POST['x1'];
     $angle['x2']['0'] = $_POST['x2'];
     $angle['y1']['0'] = $_POST['y1'];
     $angle['y2']['0'] = $_POST['y2'];
     $angle['w']['0'] = $_POST['w'];
     $angle['h']['0'] = $_POST['h'];
     if (!$this->upload->do_upload('site_logo')) {
         $up = array('error' => $this->upload->display_errors());
     } else {
         $data = $this->upload->data();
         $_POST['settings']['site_logo'] = $data['file_name'];
         crop($this->upload->data(), $angle);
     }
     $this->settings_model->newSettings($this->input->post('settings'));
     $this->session->set_flashdata('app_success', 'Settings successfully updated!');
     redirect(strtolower(__CLASS__) . '/general_settings');
 }
开发者ID:jkmorayur,项目名称:jk-admin,代码行数:25,代码来源:settings.php

示例2: update

 public function update()
 {
     /**/
     $data = array();
     if (isset($_FILES['cat_image']['name']) && !empty($_FILES['cat_image']['name'])) {
         $newFileName = rand(9999999, 0) . $_FILES['cat_image']['name'];
         $config['upload_path'] = './assets/uploads/category/';
         $config['allowed_types'] = 'gif|jpg|png';
         $config['file_name'] = $newFileName;
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload('cat_image')) {
             array('error' => $this->upload->display_errors());
         } else {
             $data = array('upload_data' => $this->upload->data());
             crop($this->upload->data(), $this->input->post());
         }
         /**/
         $_POST['category']['cat_image'] = isset($data['upload_data']['file_name']) ? $data['upload_data']['file_name'] : '';
     }
     if ($this->category_model->updateCategory($_POST['category'])) {
         $this->session->set_flashdata('app_success', 'Category successfully updated!');
     } else {
         $this->session->set_flashdata('app_error', "Can't update category!");
     }
     redirect(strtolower(__CLASS__));
 }
开发者ID:jkmorayur,项目名称:gtech,代码行数:26,代码来源:category.php

示例3: resize

function resize($image, $width = false, $height = false)
{
    $original_width = imageSX($image);
    $original_height = imageSY($image);
    // ---------------------------------------------------------------------
    if ($height != false && is_numeric($height)) {
        $size["height"] = $height;
    } else {
        $size["height"] = $width * $original_height / $original_width;
    }
    // ---------------------------------------------------------------------
    if ($width != false && is_numeric($width)) {
        $size["width"] = $width;
    } else {
        $size["width"] = $height * $original_width / $original_height;
    }
    // ---------------------------------------------------------------------
    if ($original_width / $original_height > $size["width"] / $size["height"]) {
        // crop from either sides
        $rect_width = $original_height * ($size["width"] / $size["height"]);
        return crop($image, array("left" => ($original_width - $rect_width) / 2, "top" => 0, "width" => $rect_width, "height" => $original_height), array("width" => $size["width"], "height" => $size["height"]));
    } else {
        // crop from bottom
        $rect_height = $original_width * ($size["height"] / $size["width"]);
        return crop($image, array("left" => 0, "top" => 0, "width" => $original_width, "height" => $rect_height), array("width" => $size["width"], "height" => $size["height"]));
    }
}
开发者ID:vishva8kumara,项目名称:tinyF-x2-,代码行数:27,代码来源:image_magic.php

示例4: processCropSample

function processCropSample()
{
    $response = ["success" => 0, "msg" => "Ops! Sample not cropped"];
    if (isset($_POST["sample"]) && is_numeric($_POST["sample"]) && $_POST["sample"] > 0 && isset($_POST["crop_data"])) {
        $sample_id = $_POST["sample"];
        $data = $_POST["crop_data"];
        $sample = AnnotationSample::find($sample_id);
        if (crop($sample->image, $data)) {
            $sample->crop_x = round($data["x"], 2);
            $sample->crop_y = round($data["y"], 2);
            $sample->crop_width = round($data["width"], 2);
            $sample->crop_height = round($data["height"], 2);
            $sample->lock = 0;
            if ($sample->save()) {
                $_SESSION[SESSION_KEY_CROP_COUNTER]++;
                $response = ["success" => 1, "msg" => "Cropped succesfully"];
            }
        } else {
            $response = ["success" => 0, "msg" => "Failed to crop the image file"];
        }
    }
    return json_encode($response);
}
开发者ID:aarcosg,项目名称:CVUtilsWeb,代码行数:23,代码来源:cropper_controller.php

示例5: PHP_slashes

 $SQL_STYLE = "`style` = '{$style}',";
 if (!empty($_POST['desimg']) && $_FILES['img']['size'] <= 0 && $_POST['imgsz'] == $sizex) {
     $img = PHP_slashes(htmlspecialchars(strip_tags($_POST['desimg'])));
     $SQL_IMG = '`img` = "' . $img . '",';
 } else {
     if ($style != 12) {
         if ($_FILES['img']['size'] > 0) {
             $px = @GetImageSize($_FILES['img']['tmp_name']);
             if ($px[0] >= $size[0] && $px[1] >= $size[1]) {
                 if ($_FILES['img']['type'] == 'image/jpeg' or $_FILES['img']['type'] == 'image/gif' or $_FILES['img']['type'] == 'image/png') {
                     $rand = rand(100, 99999);
                     $name = time() . '_' . $rand;
                     $read_sql = date('Y-m') . '/' . $name . '.jpg';
                     move_uploaded_file($_FILES['img']['tmp_name'], '../img/uploads/news/read/' . $read_sql);
                     if ($px[0] > $size[0] && $px[1] > $size[1]) {
                         crop('../img/uploads/news/read/' . $read_sql, $_POST['left'], $_POST['top'], $size[0], $size[1]);
                     }
                     $SQL_IMG = '`img` = "' . $read_sql . '",';
                     $SQL_STYLE = "`style` = '{$style}',";
                 } else {
                     if ($operation == 1) {
                         $error[0] = "გთხოვთ აირჩიოთ JPG,PNG,GIF ფორმატის ფოტო";
                     }
                 }
             } else {
                 if ($operation == 1) {
                     $error[0] = "ფოტოს სიგრძე სავალდებულოა იყოს არანაკლებ " . $size[0] . "px და სიმაღლე არანაკლებ " . $size[1] . "px";
                 }
             }
         } else {
             if ($operation == 1) {
开发者ID:Vatia13,项目名称:funtime,代码行数:31,代码来源:.model.php

示例6: resize_bounding

     //			if(isset($_GET['c'])){ imagepng($ttimage); die();}
     //			 imagepng($ttimage); die();
     //			image_to_text($ttimage);
     $kttimage = resize_bounding($ttimage);
     //			if(isset($_GET['d'])){ imagepng($kttimage); die();}
     //			 imagepng($kttimage); die();
     $i = thinzs_np($kttimage);
     imagepng($i);
     //imagepng(thin_b($timage));
     die;
     $box['tlx'] += BOX_EDGE;
     $box['tly'] += BOX_EDGE;
     $box['brx'] -= BOX_EDGE;
     $box['bry'] -= BOX_EDGE;
     header("Content-type: image/png");
     imagepng(crop($im, applytransforms($box, $row)));
 } else {
     if (isset($_GET['zoom'])) {
         header("Content-type: image/png");
         echo $row['image'];
     } else {
         $width = imagesx($im);
         $height = imagesy($im);
         $newwidth = DISPLAY_PAGE_WIDTH;
         $newheight = round($height * (DISPLAY_PAGE_WIDTH / $width));
         $thumb = imagecreatetruecolor($newwidth, $newheight);
         imagepalettecopy($thumb, $im);
         imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
         header("Content-type: image/png");
         imagepng($thumb);
     }
开发者ID:bimbam123,项目名称:quexf,代码行数:31,代码来源:showpage.php

示例7: catalog


//.........这里部分代码省略.........

                            $item['fields'][stripslashes($value)] = stripslashes($field);

                        }

                    } else { break; }
                }
            }

            $items[] = $item;
        }

        if (!@$pagemode){
            $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%');
        } else {

            if ($pagemode=='findfirst'){
                $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%/find-first/'.urlencode(urlencode($query)));
            }

            if ($pagemode=='find'){
                $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%/find/'.urlencode(urlencode($query)));
            }

        }

        // SEO
        if($cat['NSLevel'] > 0){

            // meta description
            if($cat['meta_desc']){
                $meta_desc = $cat['meta_desc'];
            } elseif(mb_strlen(strip_tags($cat['description']))>=250){
                $meta_desc = crop($cat['description']);
            } else {
                $meta_desc = $cat['title'];
            }
            $inPage->setDescription($meta_desc);
            // meta keywords
            if($cat['meta_keys']){
                $meta_keys = $cat['meta_keys'];
            } elseif($items){
                foreach($items as $c){
                    $k[] = $c['title'];
                }
                $meta_keys = implode(', ', $k);
            } else {
                $meta_keys = $cat['title'];
            }
            $inPage->setKeywords($meta_keys);

        }

        $tpl->assign('cfg', $cfg)->
              assign('page', $page)->
              assign('search_details', $search_details)->
              assign('fstruct', $fstruct)->
              assign('items', $items)->
              assign('pagebar', $pagebar)->
              display('com_catalog_view.tpl');

        return true;

    }

    //////////////////////////// VIEW ITEM DETAILS ///////////////////////////////////////////////////////////////////////
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:67,代码来源:frontend.php

示例8: blogs


//.........这里部分代码省略.........
        if (!$blog) {
            $blog_user_id = cmsCore::c('db')->get_field('cms_blogs', "id = '{$post['blog_id']}' AND owner = 'club'", 'user_id');
            if($blog_user_id){
                cmsCore::redirect('/clubs/'.$blog_user_id.'_'.$post['seolink'].'.html', '301');
            }
        }

        if (!$blog) { cmsCore::error404(); }

        // Проверяем сеолинк блога и делаем редирект если он изменился
        if($bloglink != $blog['seolink']) {
            cmsCore::redirect(cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink']), '301');
        }

        // право просмотра блога
        if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])){
            cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'].'<br>'.$_LANG['CLOSED_BLOG_TEXT'], 'error');
            cmsCore::redirect('/blogs');
        }

        // право просмотра самого поста
        if (!cmsUser::checkUserContentAccess($post['allow_who'], $post['user_id'])){
            cmsCore::addSessionMessage($_LANG['CLOSED_POST'].'<br>'.$_LANG['CLOSED_POST_TEXT'], 'error');
            cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($blog['seolink']));
        }

        if (cmsCore::c('user')->id) {
            cmsCore::c('page')->addHeadJS('components/blogs/js/blog.js');
        }
        cmsCore::c('page')->addPathway($blog['title'], cmsCore::m('blogs')->getBlogURL($blog['seolink']));
        cmsCore::c('page')->addPathway($post['title']);
        
        cmsCore::c('page')->setTitle($post['pagetitle'] ? $post['pagetitle'] : $post['title']);
        cmsCore::c('page')->setDescription($post['meta_desc'] ? $post['meta_desc'] : crop($post['content_html']));
        cmsCore::c('page')->setKeywords($post['meta_keys'] ? $post['meta_keys'] : $post['title']);

        if ($post['cat_id']){
            $cat = cmsCore::c('blog')->getBlogCategory($post['cat_id']);
        }

        $post['tags'] = cmsTagBar('blogpost', $post['id']);

        $is_author = (cmsCore::c('user')->id && cmsCore::c('user')->id == $post['user_id']);
        
        // увеличиваем кол-во просмотров
        if (!$is_author) {
            cmsCore::c('db')->setFlag('cms_blog_posts', $post['id'], 'hits', $post['hits']+1);
        }

        cmsPage::initTemplate('components', 'com_blog_view_post')->
            assign('post', $post)->
            assign('blog', $blog)->assign('cat', $cat)->
            assign('is_author', $is_author)->
            assign('is_writer', cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id))->
            assign('myblog', (cmsCore::c('user')->id && cmsCore::c('user')->id == $blog['user_id']))->
            assign('is_admin', cmsCore::c('user')->is_admin)->
            assign('karma_form', cmsKarmaForm('blogpost', $post['id'], $post['rating'], $is_author))->
            assign('navigation', cmsCore::c('blog')->getPostNavigation($post['id'], $blog['id'], cmsCore::m('blogs'), $blog['seolink']))->
            display();

        if ($inCore->isComponentEnable('comments') && $post['comments']) {
            cmsCore::includeComments();
            comments('blog', $post['id'], array(), $is_author);
        }
    }
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:66,代码来源:frontend.php

示例9: clubs


//.........这里部分代码省略.........

	$total = $model->getClubsCount();

        $clubs = $model->getClubs();
	if (!$clubs && $page > 1) { return false; }
        
        if ($page > 1) {
            foreach ($clubs as $c) {
                $keys[] = $c['title'];
            }
            $inPage->setKeywords(implode(',', $keys));
        }

	cmsPage::initTemplate('components', 'com_clubs_view')->
            assign('pagetitle', $pagetitle)->
            assign('can_create', ($inUser->id && $model->config['cancreate'] || $inUser->is_admin))->
            assign('clubs', $clubs)->
            assign('total', $total)->
            assign('pagination', cmsPage::getPagebar($total, $page, $model->config['perpage'], '/clubs/page-%page%'))->
            display();

}
/////////////////////// ПРОСМОТР КЛУБА /////////////////////////////////////////
if ($do=='club'){
    $club = $model->getClub($id);
    if (!$club) { return false; }

    if (!$club['published'] && !$inUser->is_admin) { return false; }

    $inPage->setTitle($club['pagetitle'] ? $club['pagetitle'] : $club['title']);
    $inPage->setKeywords($club['meta_keys'] ? $club['meta_keys'] : $club['title']);
    if (!$club['meta_desc']) {
        if ($club['description']) {
            $inPage->setDescription(crop($club['description']));
        } else {
            $inPage->setDescription($club['title']);
        }
    } else {
        $inPage->setDescription($club['meta_desc']);
    }
        
    $inPage->addPathway($club['title']);
    $inPage->addHeadJsLang(array('NEW_POST_ON_WALL','CONFIRM_DEL_POST_ON_WALL'));

    // Инициализируем участников клуба
    $model->initClubMembers($club['id']);
    // права доступа
    $is_admin  = $inUser->is_admin || ($inUser->id == $club['admin_id']);
    $is_moder  = $model->checkUserRightsInClub('moderator');
    $is_member = $model->checkUserRightsInClub('member');

	// Приватный или публичный клуб
    $is_access = true;
    if ($club['clubtype']=='private' && (!$is_admin && !$is_moder && !$is_member)){
        $is_access = false;
    }

	// Общее количество участников
    $club['members'] = $model->club_total_members;
	// Общее количество участников
    $club['moderators'] = $model->club_total_moderators;

	// Массив членов клуба
	if($club['members']){
		$inDB->limit($model->config['club_perpage']);
		$club['members_list'] = $model->getClubMembers($club['id'], 'member');
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:67,代码来源:frontend.php

示例10: imagecreatefromstring

             $sql = "SELECT *\r\n\t\t\t\t\tFROM formpages\r\n\t\t\t\t\tWHERE pid = {$pid} and fid = {$fid}";
             $row = $db->GetRow($sql);
             if ($row['filename'] == '') {
                 $im = imagecreatefromstring($row['image']);
             } else {
                 $im = imagecreatefrompng(IMAGES_DIRECTORY . $row['filename']);
             }
         }
         $sql = "SELECT count(*) as c FROM ocrtrain\r\n\t\t\t\tWHERE fid = '{$fid}' and vid = '{$vid}' and bid = '{$bid}'";
         $cc = $db->GetRow($sql);
         if ($cc['c'] > 0) {
             print T_("Found duplicate") . " {$fid} {$vid} {$bid}";
         } else {
             $row['width'] = imagesx($im);
             $row['height'] = imagesy($im);
             $image = crop($im, applytransforms($box, $row));
             $a1 = kfill_modified($image, 5);
             $a2 = remove_boundary_noise($a1, 2);
             $timage = resize_bounding($a2);
             $bimage = thinzs_np($timage);
             $t = sector_distance($bimage);
             $count++;
             $sql = "INSERT INTO ocrtrain (ocrtid,val,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,fid,vid,bid,kb)\r\n\t\t\t\t\tVALUES (NULL,'{$val}','{$t[0][1]}','{$t[0][2]}','{$t[0][3]}','{$t[0][4]}','{$t[0][5]}','{$t[0][6]}','{$t[0][7]}','{$t[0][8]}','{$t[0][9]}','{$t[0][10]}','{$t[0][11]}','{$t[0][12]}','{$t[1][1]}','{$t[1][2]}','{$t[1][3]}','{$t[1][4]}','{$fid}','{$vid}','{$bid}','{$kb}')";
             $db->Execute($sql);
         }
     }
 }
 print T_("Trained") . ": {$count} " . T_("characters");
 //generate kb
 generate_kb($kb);
 print T_("Generated KB");
开发者ID:ddrmoscow,项目名称:queXF,代码行数:31,代码来源:icrtrain.php

示例11: forum

function forum()
{
    $inCore = cmsCore::getInstance();
    $inPage = cmsPage::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    $model = new cms_model_forum();
    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) {
        cmsCore::loadClass('billing');
    }
    global $_LANG;
    $pagetitle = $inCore->getComponentTitle();
    $inPage->addPathway($pagetitle, '/forum');
    $inPage->setTitle($pagetitle);
    $inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $pagetitle);
    $inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $pagetitle);
    $id = cmsCore::request('id', 'int', 0);
    $do = $inCore->do;
    $page = cmsCore::request('page', 'int', 1);
    $inPage->addHeadJS('components/forum/js/common.js');
    $inPage->addHeadJsLang(array('CONFIRM_DELETE_POLL', 'CONFIRM_DEL_POST', 'CONFIRM_DEL_THREAD', 'MOVE_THREAD', 'MOVE_POST', 'RENAME_THREAD', 'CONFIRM_DELETE_FILE', 'SELECT_NEW_FILE_UPLOAD', 'SELECT_TEXT_QUOTE', 'CONFIRM_DELETE_ALL_USER_POSTS'));
    //============================================================================//
    //=============================== Список Форумов  ============================//
    //============================================================================//
    if ($do == 'view') {
        $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . $_LANG['FORUMS'] . '" href="' . HOST . '/rss/forum/all/feed.rss">');
        $forums = $model->getForums();
        cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $pagetitle)->assign('forums', $forums)->assign('forum', array())->assign('user_id', $inUser->id)->assign('cfg', $model->config)->display('com_forum_list.tpl');
    }
    //============================================================================//
    //================ Список тем форума + список подфорумов  ====================//
    //============================================================================//
    if ($do == 'forum') {
        $forum = $model->getForum($id);
        if (!$forum) {
            cmsCore::error404();
        }
        $forum = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $forum);
        $moderators = $model->getForumModerators($forum['moder_list']);
        // опции просмотра
        $order_by = cmsCore::getSearchVar('order_by', 'pubdate');
        $order_to = cmsCore::getSearchVar('order_to', 'desc');
        if (!in_array($order_by, array('pubdate', 'title', 'post_count', 'hits'))) {
            $order_by = 'pubdate';
        }
        if (!in_array($order_to, array('asc', 'desc'))) {
            $order_to = 'desc';
        }
        $daysprune = (int) cmsCore::getSearchVar('daysprune');
        if (!cmsCore::checkContentAccess($forum['access_list'])) {
            cmsPage::includeTemplateFile('special/accessdenied.php');
            return;
        }
        $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars($forum['title']) . '" href="' . HOST . '/rss/forum/' . $forum['id'] . '/feed.rss">');
        $inPage->setTitle($forum['pagetitle'] ? $forum['pagetitle'] : $forum['title']);
        $inPage->setDescription($forum['meta_desc'] ? $forum['meta_desc'] : crop($forum['description'] ? $forum['description'] : $forum['title']));
        $inPage->setKeywords($forum['meta_keys'] ? $forum['meta_keys'] : $forum['title']);
        // Получаем дерево форумов
        $path_list = $inDB->getNsCategoryPath('cms_forums', $forum['NSLeft'], $forum['NSRight'], 'id, title, access_list, moder_list');
        // Строим глубиномер
        if ($path_list) {
            $path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list);
            foreach ($path_list as $pcat) {
                if (!cmsCore::checkContentAccess($pcat['access_list'])) {
                    cmsPage::includeTemplateFile('special/accessdenied.php');
                    return;
                }
                $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']);
            }
        }
        // Получим подфорумы
        $model->whereNestedForum($forum['NSLeft'], $forum['NSRight']);
        $sub_forums = $model->getForums();
        cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $forum['title'])->assign('forums', $sub_forums)->assign('forum', $forum)->assign('cfg', $model->config)->assign('user_id', $inUser->id)->display('com_forum_list.tpl');
        // Получим темы
        if ($daysprune) {
            $model->whereDayIntervalIs($daysprune);
        }
        $model->whereForumIs($forum['id']);
        $inDB->orderBy('t.pinned', 'DESC, t.' . $order_by . ' ' . $order_to);
        $inDB->limitPage($page, $model->config['pp_forum']);
        $threads = $model->getThreads();
        if (!$threads && $page > 1) {
            cmsCore::error404();
        }
        cmsPage::initTemplate('components', 'com_forum_view')->assign('threads', $threads)->assign('show_panel', true)->assign('order_by', $order_by)->assign('order_to', $order_to)->assign('daysprune', $daysprune)->assign('moderators', $moderators)->assign('pagination', cmsPage::getPagebar($forum['thread_count'], $page, $model->config['pp_forum'], '/forum/' . $forum['id'] . '-%page%'))->display('com_forum_view.tpl');
    }
    //============================================================================//
    //======================== Просмотр темы форума  =============================//
    //============================================================================//
    if ($do == 'thread') {
        $thread = $model->getThread($id);
        if (!$thread) {
            cmsCore::error404();
        }
        // Строим глубиномер
        $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list');
        if ($path_list) {
            $path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list);
//.........这里部分代码省略.........
开发者ID:deltas1,项目名称:icms1,代码行数:101,代码来源:frontend.php

示例12: definetomap

function definetomap($zoom, $pid, $filename)
{
    $tb = array('t', 'b');
    $lr = array('l', 'r');
    $vh = array('vert', 'hori');
    $el = array('tlx', 'tly', 'brx', 'bry');
    $image = imagecreatefrompng($filename . $pid . ".png");
    $width = imagesx($image);
    $height = imagesy($image);
    $page = defaultpage($width - 1, $height - 1);
    $offset = offset($image, false, 0, $page);
    //draw lines of corner edges
    $vert = true;
    $linewidth = 8;
    $lc = 0;
    foreach ($offset as $coord) {
        if ($vert == true) {
            $top = 0;
            if ($lc > 3) {
                $top = $height / $zoom - $height / 4 / $zoom;
            }
            //drawing a vertical line so use $coord as $x
            print "<div style='position: absolute; top:" . $top . "px; left:" . $coord / $zoom . "px; width:" . $linewidth / $zoom . "px; height:" . $height / 4 / $zoom . "px; background-color: blue;'></div>";
            $vert = false;
        } else {
            //drawing a horizontal line so use $coord as $y
            $left = 0;
            if ($lc == 3 || $lc == 7) {
                $left = $width / $zoom - $width / 4 / $zoom;
            }
            print "<div style='position: absolute; top:" . $coord / $zoom . "px; left:" . $left . "px; width:" . $width / 4 / $zoom . "px; height:" . $linewidth / $zoom . "px; background-color: blue;'></div>";
            $vert = true;
        }
        $lc++;
    }
    foreach ($tb as $a) {
        foreach ($lr as $b) {
            foreach ($vh as $c) {
                $vname = "{$a}{$b}" . "_" . $c . "_";
                $tlx = $page[strtoupper($vname . "tlx")];
                $tly = $page[strtoupper($vname . "tly")];
                $brx = $page[strtoupper($vname . "brx")];
                $bry = $page[strtoupper($vname . "bry")];
                print "<div id='{$vname}' style='position: absolute; top:" . $tly / $zoom . "px; left: " . $tlx / $zoom . "px; width:" . ($brx - $tlx) / $zoom . "px; height:" . ($bry - $tly) / $zoom . "px; background-color: green; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>" . $vname . "</div></div>";
            }
        }
    }
    $btlx = floor(BARCODE_TLX_PORTION * $width);
    if ($btlx <= 0) {
        $btlx = 1;
    }
    $btly = floor(BARCODE_TLY_PORTION * $height);
    if ($btly <= 0) {
        $btly = 1;
    }
    $bbrx = floor(BARCODE_BRX_PORTION * $width);
    if ($bbrx <= 0) {
        $bbrx = 1;
    }
    $bbry = floor(BARCODE_BRY_PORTION * $height);
    if ($bbry <= 0) {
        $bbry = 1;
    }
    $barcodeimage = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
    $barcode = barcode($barcodeimage);
    if ($barcode === false) {
        $barcode = T_("NO BARCODE DETECTED");
    } else {
        if (strlen($barcode) != BARCODE_LENGTH_PID) {
            $barcode = T_("Detected but not BARCODE_LENGTH_PID length") . ": " . $barcode;
        } else {
            $barcode = T_("Detected") . ": " . $barcode;
        }
    }
    print "<div id='barcodebox'  style='position: absolute; top:" . $btly / $zoom . "px; left: " . $btlx / $zoom . "px; width:" . ($bbrx - $btlx) / $zoom . "px; height:" . ($bbry - $btly) / $zoom . "px; background-color: brown; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>{$barcode}</div></div>";
}
开发者ID:bimbam123,项目名称:quexf,代码行数:76,代码来源:pagetest.php

示例13: crop

			<input type="submit" value="Editar" id="editar_perfil" class="btn_submit"/>
		</form>
	</div>
	<div class="aba2 aba <?php 
echo $aba2;
?>
">
		<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['w'])) {
        $x = (int) $_POST['x'];
        $y = (int) $_POST['y'];
        $w = (int) $_POST['w'];
        $h = (int) $_POST['h'];
        $img = $_POST['img'];
        $crop = crop($img, $x, $y, $w, $h);
        if ($crop) {
            if ($logado->foto != '') {
                unlink('uploads/' . $logado->foto);
                $upd_foto = $pdo->prepare("UPDATE `usuarios` SET `foto` = ? WHERE `id` = ?");
                if ($upd_foto->execute(array($crop, $logado->id))) {
                    echo '<div class="aviso green">Imagem cortada com sucesso</div>';
                }
            } else {
                $upd_foto = $pdo->prepare("UPDATE `usuarios` SET `foto` = ? WHERE `id` = ?");
                if ($upd_foto->execute(array($crop, $logado->id))) {
                    echo '<div class="aviso green">Imagem cortada com sucesso</div>';
                }
            }
            unlink('uploads/' . $_SESSION['temp_img']);
            unset($_SESSION['temp_img']);
开发者ID:lukasdev,项目名称:mini-twitter,代码行数:31,代码来源:minha-conta.php

示例14: format_image_resize

function format_image_resize($source, $max_width = false, $max_height = false)
{
    if (!function_exists('imagecreatefromjpeg')) {
        error_handle('library missing', 'the GD library needs to be installed to run format_image_resize', __FILE__, __LINE__);
    }
    if (empty($source)) {
        return null;
    }
    if (!function_exists('resize')) {
        function resize($new_width, $new_height, $source_name, $target_name, $width, $height)
        {
            //resize an image and save to the $target_name
            $tmp = imagecreatetruecolor($new_width, $new_height);
            if (!($image = imagecreatefromjpeg(DIRECTORY_ROOT . $source_name))) {
                error_handle('could not create image', 'the system could not create an image from ' . $source_name, __FILE__, __LINE__);
            }
            imagecopyresampled($tmp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            imagejpeg($tmp, DIRECTORY_ROOT . $target_name, 100);
            imagedestroy($tmp);
            imagedestroy($image);
        }
        function crop($new_width, $new_height, $target_name)
        {
            //crop an image and save to the $target_name
            list($width, $height) = getimagesize(DIRECTORY_ROOT . $target_name);
            //by default, crop from center
            $offsetx = ($width - $new_width) / 2;
            $offsety = ($height - $new_height) / 2;
            if ($offsetx < 0) {
                $offsetx = 0;
            }
            if ($offsety < 0) {
                $offsety = 0;
            }
            //this crops from top-left
            //$offsetx = $offsety = 0;
            $tmp = imagecreatetruecolor($new_width, $new_height);
            if (!($image = @imagecreatefromjpeg(DIRECTORY_ROOT . $target_name))) {
                error_handle('could not create image', 'the system could not create an image from ' . $source_name, __FILE__, __LINE__);
            }
            imagecopyresized($tmp, $image, 0, 0, $offsetx, $offsety, $new_width, $new_height, $new_width, $new_height);
            imagejpeg($tmp, DIRECTORY_ROOT . $target_name, 100);
            imagedestroy($tmp);
            imagedestroy($image);
        }
    }
    //save to file, is file-based operation, unfortunately
    $source_name = DIRECTORY_WRITE . '/temp-source.jpg';
    $target_name = DIRECTORY_WRITE . '/temp-target.jpg';
    file_put($source_name, $source);
    //get source image dimensions
    list($width, $height) = getimagesize(DIRECTORY_ROOT . $source_name);
    if (!$width || !$height) {
        // image is probably corrupt
        echo draw_page('image corrupt', 'the uploaded image cannot be read, try opening the image in photo editing software, re-saving it, and then try again');
        exit;
    }
    //execute differently depending on target parameters
    if ($max_width && $max_height) {
        //resizing both
        if ($width == $max_width && $height == $max_height) {
            //already exact width and height, skip resizing
            copy(DIRECTORY_ROOT . $source_name, DIRECTORY_ROOT . $target_name);
        } else {
            //this was for the scenario where your target was a long landscape and you got a squarish image.
            //this doesn't work if your target is squarish and you get a long landscape
            //maybe we need a ratio function?
            //square to long scenario: input 400 x 300 (actual 1.3 ratio), target 400 x 100 (target 4) need to resize width then crop target > actual
            //long to square scenario: input 400 x 100 (actual 4 ratio), target 400 x 300 (target 1.3) need to resize height then crop target < actual
            $target_ratio = $max_width / $max_height;
            $actual_ratio = $width / $height;
            //if ($max_width >= $max_height) {
            if ($target_ratio >= $actual_ratio) {
                //landscape or square.  resize width, then crop height
                $new_height = $height / $width * $max_width;
                resize($max_width, $new_height, $source_name, $target_name, $width, $height);
            } else {
                //portrait.  resize height, then crop width
                $new_width = $width / $height * $max_height;
                resize($new_width, $max_height, $source_name, $target_name, $width, $height);
            }
            crop($max_width, $max_height, $target_name);
        }
    } elseif ($max_width) {
        //only resizing width
        if ($width == $max_width) {
            //already exact width, skip resizing
            copy(DIRECTORY_ROOT . $source_name, DIRECTORY_ROOT . $target_name);
        } else {
            //resize width
            $new_height = $height / $width * $max_width;
            resize($max_width, $new_height, $source_name, $target_name, $width, $height);
        }
    } elseif ($max_height) {
        //only resizing height
        if ($height == $max_height) {
            //already exact height, skip resizing
            copy(DIRECTORY_ROOT . $source_name, DIRECTORY_ROOT . $target_name);
        } else {
            //resize height
//.........这里部分代码省略.........
开发者ID:joshreisner,项目名称:hcfa-cc,代码行数:101,代码来源:format.php

示例15: update

 public function update()
 {
     $prdId = $this->input->post('nws_id');
     if ($this->news_model->updateNews($this->input->post())) {
         $this->load->library('upload');
         $x1 = $this->input->post('x1');
         $fileCount = count($x1);
         $up = array();
         if ($fileCount > 0) {
             for ($j = 0; $j < $fileCount; $j++) {
                 /**/
                 $data = array();
                 $angle = array();
                 $newFileName = rand(9999999, 0) . $_FILES['prd_image']['name'][$j];
                 $config['upload_path'] = './assets/uploads/news/';
                 $config['allowed_types'] = 'gif|jpg|png';
                 $config['file_name'] = $newFileName;
                 $this->upload->initialize($config);
                 $angle['x1']['0'] = $_POST['x1'][$j];
                 $angle['x2']['0'] = $_POST['x2'][$j];
                 $angle['y1']['0'] = $_POST['y1'][$j];
                 $angle['y2']['0'] = $_POST['y2'][$j];
                 $angle['w']['0'] = $_POST['w'][$j];
                 $angle['h']['0'] = $_POST['h'][$j];
                 $_FILES['prd_image_tmp']['name'] = $_FILES['prd_image']['name'][$j];
                 $_FILES['prd_image_tmp']['type'] = $_FILES['prd_image']['type'][$j];
                 $_FILES['prd_image_tmp']['tmp_name'] = $_FILES['prd_image']['tmp_name'][$j];
                 $_FILES['prd_image_tmp']['error'] = $_FILES['prd_image']['error'][$j];
                 $_FILES['prd_image_tmp']['size'] = $_FILES['prd_image']['size'][$j];
                 if (!$this->upload->do_upload('prd_image_tmp')) {
                     $up = array('error' => $this->upload->display_errors());
                 } else {
                     $data = array('upload_data' => $this->upload->data());
                     crop($this->upload->data(), $angle);
                     $this->news_model->addImages(array('nwi_news_id' => $prdId, 'nwi_image' => $data['upload_data']['file_name']));
                 }
             }
         }
         $this->session->set_flashdata('app_success', 'News successfully updated!');
     } else {
         $this->session->set_flashdata('app_error', "Can't updated news!");
     }
     redirect(strtolower(__CLASS__));
 }
开发者ID:jkmorayur,项目名称:gtech,代码行数:44,代码来源:news_and_events.php


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