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


PHP util::image_compress方法代码示例

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


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

示例1: douploadimg

 function douploadimg()
 {
     $imgname = $_FILES['photofile']['name'];
     $extname = file::extname($imgname);
     $destfile = $_ENV['attachment']->makepath($extname);
     $arrupload = file::uploadfile($_FILES['photofile'], $destfile);
     if ($arrupload['result'] == true) {
         if (isset($this->setting['watermark'])) {
             $_ENV['watermark']->image($destfile, $destfile);
         }
         $uid = $this->user['uid'] ? $this->user['uid'] : 0;
         $did = $this->get['2'] ? $this->get['2'] : 0;
         $_ENV['attachment']->add_attachment($uid, $did, $imgname, $destfile, htmlspecialchars($this->post['picAlt']), $extname);
         $img_width_big = $this->setting['img_width_big'];
         $img_height_big = $this->setting['img_height_big'];
         $img_width_small = $this->setting['img_width_small'];
         $img_height_small = $this->setting['img_height_small'];
         $img_width_big = is_numeric($img_width_big) ? $img_width_big : 300;
         $img_height_big = is_numeric($img_height_big) ? $img_height_big : 300;
         $img_width_small = is_numeric($img_width_small) ? $img_width_small : 140;
         $img_height_small = is_numeric($img_height_small) ? $img_height_small : 140;
         $iamge300 = util::image_compress($destfile, '', $img_width_big, $img_height_big, '_s');
         $iamge140 = util::image_compress($destfile, '', $img_width_small, $img_height_small, '_140');
         $_ENV['user']->add_credit($uid, 'attachment-upload', $this->setting['credit_upload'], $this->setting['coin_upload']);
     } else {
         $_ENV['attachment']->showmsg($arrupload['msg']);
         exit;
     }
     $images = $this->post['picWidthHeight'] == 1 ? $iamge300['tempurl'] : $iamge140['tempurl'];
     if (empty($_FILES) === false) {
         $_ENV['attachment']->insert_image_js($images, $destfile);
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:33,代码来源:attachment.php

示例2: doedit

 function doedit()
 {
     if (!isset($this->post['submit'])) {
         $id = $this->get[2];
         $gift = $_ENV['gift']->get($id);
         $this->view->assign("gift", $gift);
         $this->view->display('admin_editgift');
     } else {
         $id = trim($this->post['id']);
         $gift = $_ENV['gift']->get($id);
         $title = htmlspecialchars(trim($this->post['title']));
         $credit = trim($this->post['credit']);
         $description = htmlspecialchars(trim($this->post['description']));
         $imgname = $_FILES['giftfile']['name'];
         /*
         if($gift['image']){
         	$destfile=str_replace('_s.', '.', $gift['image']);
         }else{
         	$extname=file::extname($imgname);
         	$destfile = 'uploads/gift/'.util::random(8).'.'.$extname;
         }
         */
         if ('' != $imgname) {
             $extname = file::extname($imgname);
             $destfile = 'uploads/gift/' . util::random(8) . '.' . $extname;
             file::uploadfile($_FILES['giftfile'], $destfile);
             util::image_compress($destfile, '', 500, 500, '');
             $iamge = util::image_compress($destfile, '', 106, 106, '_s');
             $destfile = $iamge['tempurl'];
         }
         $_ENV['gift']->edit($id, $title, $credit, $description, $destfile);
         $this->message($this->view->lang['usermanageOptSuccess'], 'index.php?admin_gift-search');
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:34,代码来源:admin_gift.php

示例3: doeditxml

 function doeditxml()
 {
     if (!isset($this->post['stylesave']) && !isset($this->post['styleshare'])) {
         $xmlcon = $_ENV['theme']->read_xml($this->get[2]);
         $this->view->assign('stylename', $this->get[2]);
         $this->view->assign('style', $xmlcon);
         $this->view->assign('share', $this->get[3]);
         $this->view->display('admin_themexml_edit');
     } else {
         if ($_FILES['styleimg']['name'] != '') {
             $image = $_FILES['styleimg'];
             $extname = file::extname($image['name']);
             if ($extname == 'jpg') {
                 $destfile = 'style/' . $this->get[2] . '/screenshot.' . $extname;
                 $result = file::uploadfile($image, $destfile);
                 if ($result['result']) {
                     util::image_compress($destfile, NULL, 158, 118);
                 } else {
                     $this->message($result['msg'], 'BACK');
                 }
             } else {
                 $this->message($this->view->lang['uploadFormatWrong'], 'BACK');
             }
         }
         //insert into db
         $style = $this->post['style'];
         $style['hdversion'] = HDWIKI_VERSION;
         $style['path'] = trim($this->get[2]);
         $style['charset'] = $_ENV['theme']->style_charset($style[path]);
         $stylecon = $_ENV['theme']->add_check_style($style['path']);
         if ($stylecon == null) {
             $_ENV['theme']->add_style($style);
         } else {
             $_ENV['theme']->update_style($style);
         }
         //得到需要插入的blocks的sql。
         $style['sql'] = '';
         $blocks = $_ENV['theme']->get_blocks_by_theme($this->get[2]);
         if ($blocks) {
             $insertsql = "INSERT INTO wiki_block (theme,file,area,areaorder,block,fun,tpl,params) VALUES ";
             foreach ($blocks as $val) {
                 $insertsql .= "( '{$val['theme']}','{$val['file']}','{$val['area']}','{$val['areaorder']}','{$val['block']}','{$val['fun']}','{$val['tpl']}','{$val['params']}' ),";
             }
             $style['sql'] = substr($insertsql, 0, -1);
         }
         //write to xml
         $_ENV['theme']->write_xml($style);
         if (isset($this->post['stylesubmit'])) {
             $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme');
         } else {
             if (isset($this->post['stylesave'])) {
                 $this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme-editxml-' . $style[path] . '-share');
             } else {
                 if (isset($this->post['styleshare'])) {
                     //check
                     $filename = 'style/' . $style['path'] . '/share.lock';
                     if (is_file($filename)) {
                         $this->message($this->view->lang['style_share_lock'] . $filename, 'BACK');
                     } else {
                         file::writetofile($filename, $a = '');
                     }
                     //zip
                     require HDWIKI_ROOT . "/lib/zip.class.php";
                     $zip = new Zip();
                     $filedir = array('style/' . $style['path'], 'view/' . $style['path'], 'block/' . $style['path']);
                     $zipdir = array('hdwiki/style/' . $style['path'], 'hdwiki/view/' . $style['path'], 'hdwiki/block/' . $style['path']);
                     file::forcemkdir(HDWIKI_ROOT . '/data/tmp/');
                     $tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
                     @$zip->zip_dir($filedir, $tmpname, $zipdir);
                     //share
                     if (is_file($tmpname)) {
                         $zip_content = file::readfromfile($tmpname);
                         $upload_url = $this->setting['app_url'] . "/hdapp.php?action=upload&type=template";
                         $data = 'data=' . base64_encode($zip_content);
                         unlink($tmpname);
                         if ('1' == @util::hfopen($upload_url, 0, $data)) {
                             $this->message($this->view->lang['styleShareSuccess'], 'index.php?admin_theme');
                         } else {
                             $this->message($this->view->lang['styleShareFaile'], 'index.php?admin_theme');
                         }
                     } else {
                         $this->message($this->view->lang['styleFileZipFail'], 'index.php?admin_theme');
                     }
                 }
             }
         }
     }
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:88,代码来源:admin_theme.php

示例4: setfocusimg

 function setfocusimg($img)
 {
     if ('' == $img) {
         return '';
     }
     if (substr($img, 0, strlen(WIKI_URL)) == WIKI_URL) {
         $img = substr($img, strlen(WIKI_URL) + 1);
     }
     if ("http://" == substr($img, 0, 7) && substr($img, 0, strlen(WIKI_URL)) != WIKI_URL) {
         $tmpname = 'uploads/' . date("Ym") . "/" . util::random() . '.' . file::extname($img);
         if ($pic_content = @util::hfopen($img)) {
             file::forcemkdir(dirname($tmpname));
             if (file::writetofile($tmpname, $pic_content)) {
                 $img = $tmpname;
             }
         }
     }
     $compress = util::image_compress($img, 's_f_', 100, 75);
     if (!$compress['result']) {
         return '';
     }
     util::image_compress($img, 'f_', 152, 114);
     @unlink($tmpname);
     return $compress['tempurl'];
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:25,代码来源:doc.class.php

示例5: upload_img

 function upload_img($uploadimg, $filename)
 {
     $counts = count($uploadimg);
     if ($counts != 0) {
         for ($i = 0; $i < $counts; $i++) {
             $imgname = $uploadimg[$i]['name'];
             $extname = file::extname($imgname);
             $destfile = HDWIKI_ROOT . '/style/' . $filename . '/' . $uploadimg[$i]['rename'] . "." . $extname;
             $result = file::uploadfile($uploadimg[$i], $destfile);
             if ($result['result'] && $uploadimg[$i]['rename'] == 'screenshot') {
                 util::image_compress($destfile, NULL, 158, 118);
             }
             $success++;
         }
     }
     return $success;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:17,代码来源:theme.class.php


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