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


PHP image::save方法代码示例

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


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

示例1: nv_resize_crop_image

function nv_resize_crop_image($img_path, $width, $height, $module_name = '', $id = 0)
{
    $new_img_path = '';
    if (file_exists($img_path)) {
        $imginfo = nv_is_image($img_path);
        $basename = basename($img_path);
        if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
            $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $id . '_\\1_' . $width . '-' . $height . '\\2', $basename);
            if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                $new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
            } else {
                $img_path = new image($img_path, NV_MAX_WIDTH, NV_MAX_HEIGHT);
                $thumb_width = $width;
                $thumb_height = $height;
                $maxwh = max($thumb_width, $thumb_height);
                if ($img_path->fileinfo['width'] > $img_path->fileinfo['height']) {
                    $width = 0;
                    $height = $maxwh;
                } else {
                    $width = $maxwh;
                    $height = 0;
                }
                $img_path->resizeXY($width, $height);
                $img_path->cropFromCenter($thumb_width, $thumb_height);
                $img_path->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
                if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                    $new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                }
            }
        }
    }
    return $new_img_path;
}
开发者ID:hongoctrien,项目名称:module-code,代码行数:33,代码来源:functions.php

示例2: XTemplate

 function nv_news_block_newscenter($block_config)
 {
     global $module_data, $module_name, $module_file, $global_array_cat, $global_config, $lang_module, $db, $module_config, $module_info;
     $module_name = 'news';
     $module_data = 'news';
     $xtpl = new XTemplate('block_newscenter.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/blocks');
     $xtpl->assign('lang', $lang_module);
     $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
     $db->sqlreset()->select('id, catid, publtime, title, alias, hometext, homeimgthumb, homeimgfile')->from(NV_PREFIXLANG . '_' . $module_data . '_rows')->where('status= 1')->order('publtime DESC')->limit(5);
     $list = nv_db_cache($db->sql(), 'id', $module_name);
     $i = 1;
     foreach ($list as $row) {
         $row['publtime'] = nv_date('m/d/Y', $row['publtime']);
         $row['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$row['catid']]['alias'] . '/' . $row['alias'] . '-' . $row['id'] . $global_config['rewrite_exturl'];
         $row['title0'] = nv_clean60(strip_tags($row['title']), $i == 1 ? 50 : 30);
         $row['hometext'] = nv_clean60(strip_tags($row['hometext']), 260);
         $image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
         if ($row['homeimgfile'] != '' and file_exists($image)) {
             if ($i == 1) {
                 $width = 570;
                 $height = 490;
             } else {
                 $width = 270;
                 $height = 230;
             }
             $row['imgsource'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
             $imginfo = nv_is_image($image);
             $basename = basename($image);
             if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
                 $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $row['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
                 if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                     $row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                 } else {
                     require_once NV_ROOTDIR . '/includes/class/image.class.php';
                     $_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
                     $_image->cropFromCenter($width, $height);
                     $_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
                     if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                         $row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                     }
                 }
             }
         } elseif (nv_is_url($row['homeimgfile'])) {
             $row['imgsource'] = $row['homeimgfile'];
         } elseif (!empty($module_config[$module_name]['show_no_image'])) {
             $row['imgsource'] = NV_BASE_SITEURL . $module_config[$module_name]['show_no_image'];
         } else {
             $row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no-image.png';
         }
         $xtpl->assign('main' . $i, $row);
         ++$i;
     }
     $xtpl->parse('main');
     return $xtpl->text('main');
 }
开发者ID:hongoctrien,项目名称:themes-newszine,代码行数:55,代码来源:global.block_newscenter.php

示例3: avatar

 static function avatar($image, $true_size, $size_data = array(100, 50, 32), $save_name, $save_dir = '')
 {
     foreach ($size_data as $target_size) {
         $target_img = image::create($target_size, $target_size, 'ffffff', true);
         $param = array(0, 0, 0, 0, $target_size, $target_size, $true_size, $true_size);
         $copy_result = image::copy($target_img, $image, $param, 5);
         if ($copy_result) {
             image::save($target_img, $save_name . '.gif', $save_dir . $target_size . '/');
         }
     }
 }
开发者ID:mjiong,项目名称:framework,代码行数:11,代码来源:s_picture.php

示例4: processUpload

 /**
  * Führt Upload via HTML-Form + PHP in Dateimanager durch
  * @param int $userId
  * @return array
  */
 public function processUpload($userId)
 {
     $this->uploader = $this->events->runEvent('fileUploadPhpBefore', $this->uploader);
     $tempNames = $this->uploader['tmp_name'];
     $fileNames = $this->uploader['name'];
     $fileTypes = $this->uploader['type'];
     $res = array('error' => array(), 'success' => array());
     foreach ($tempNames as $key => $value) {
         if (!is_uploaded_file($value) || !isset($fileNames[$key]) || !isset($fileTypes[$key])) {
             continue;
         }
         $ext = pathinfo($fileNames[$key], PATHINFO_EXTENSION);
         $ext = $ext ? strtolower($ext) : '';
         if (isset($fileTypes[$key]) && !in_array($fileTypes[$key], image::$allowedTypes) || !in_array($ext, image::$allowedExts)) {
             trigger_error('Unsupported filetype in ' . $fileNames[$key]);
             $res['error'][$key] = $fileNames[$key];
             continue;
         }
         $fileName = \fpcm\classes\baseconfig::$uploadDir . $fileNames[$key];
         $image = new image($fileNames[$key]);
         if (!$image->moveUploadedFile($value)) {
             trigger_error('Unable to move uploaded to to uploader folder! ' . $fileNames[$key]);
             $res['error'][$key] = $fileNames[$key];
             continue;
         }
         $image->createThumbnail();
         $image->setFiletime(time());
         $image->setUserid($userId);
         if (!$image->save()) {
             trigger_error('Unable to add uploaded file to database list! ' . $fileNames[$key]);
             $res['error'][$key] = $fileNames[$key];
             continue;
         }
         $fmThumbs = new \fpcm\model\crons\fmThumbs('fmThumbs');
         $fmThumbs->run();
         $res['success'][$key] = $fileNames[$key];
     }
     $this->events->runEvent('fileUploadPhpAfter', array('uploader' => $this->uploader, 'results' => $res));
     return $res;
 }
开发者ID:sea75300,项目名称:fanpresscm3,代码行数:45,代码来源:fileuploader.php

示例5: image

 function creat_thumbs($id, $homeimgfile, $module_name, $width = 200, $height = 150)
 {
     if ($width >= $height) {
         $rate = $width / $height;
     } else {
         $rate = $height / $width;
     }
     $image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $homeimgfile;
     if ($homeimgfile != '' and file_exists($image)) {
         $imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $homeimgfile;
         $imginfo = nv_is_image($image);
         $basename = $module_name . $width . 'x' . $height . '-' . $id . '-' . md5_file($image) . '.' . $imginfo['ext'];
         if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
             $imgsource = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
         } else {
             require_once NV_ROOTDIR . '/includes/class/image.class.php';
             $_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
             if ($imginfo['width'] <= $imginfo['height']) {
                 $_image->resizeXY($width, 0);
             } elseif ($imginfo['width'] / $imginfo['height'] < $rate) {
                 $_image->resizeXY($width, 0);
             } elseif ($imginfo['width'] / $imginfo['height'] >= $rate) {
                 $_image->resizeXY(0, $height);
             }
             $_image->cropFromCenter($width, $height);
             $_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
             if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                 $imgsource = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
             }
         }
     } elseif (nv_is_url($homeimgfile)) {
         $imgsource = $homeimgfile;
     } else {
         $imgsource = '';
     }
     return $imgsource;
 }
开发者ID:hoangvtien,项目名称:nukeviet_tab_catid,代码行数:37,代码来源:global.block_tab_catid.php

示例6: image

 function photos_thumbs($id, $file, $module_upload, $width = 270, $height = 210, $quality = 90)
 {
     if ($width >= $height) {
         $rate = $width / $height;
     } else {
         $rate = $height / $width;
     }
     $image = NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/images/' . $file;
     if ($file != '' and file_exists($image)) {
         $imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/images/' . $file;
         $imginfo = nv_is_image($image);
         $basename = $module_upload . '_' . $width . 'x' . $height . '-' . $id . '-' . md5_file($image) . '.' . $imginfo['ext'];
         if (file_exists(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename)) {
             $imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename;
         } else {
             $_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
             if ($imginfo['width'] <= $imginfo['height']) {
                 $_image->resizeXY($width, 0);
             } elseif ($imginfo['width'] / $imginfo['height'] < $rate) {
                 $_image->resizeXY($width, 0);
             } elseif ($imginfo['width'] / $imginfo['height'] >= $rate) {
                 $_image->resizeXY(0, $height);
             }
             $_image->cropFromCenter($width, $height);
             $_image->save(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/', $basename, $quality);
             if (file_exists(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename)) {
                 $imgsource = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/thumbs/' . $basename;
             }
         }
     } elseif (nv_is_url($file)) {
         $imgsource = $file;
     } else {
         $imgsource = '';
     }
     return $imgsource;
 }
开发者ID:hoangvtien,项目名称:module-photos,代码行数:36,代码来源:global.block_album_new.php

示例7: die

<?php

/**
 * @Project NUKEVIET 3.0
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
 * @Createdate 2-2-2010 12:55
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$path = htmlspecialchars(trim($nv_Request->get_string('path', 'post')), ENT_QUOTES);
if ($admin_info['allow_modify_files'] && nv_check_allow_upload_dir($path)) {
    $imagename = htmlspecialchars(trim($nv_Request->get_string('img', 'post')), ENT_QUOTES);
    $width = $nv_Request->get_int('width', 'post');
    $height = $nv_Request->get_int('height', 'post');
    require_once NV_ROOTDIR . "/includes/class/image.class.php";
    $image = new image(NV_ROOTDIR . '/' . $path . '/' . $imagename, NV_MAX_WIDTH, NV_MAX_HEIGHT);
    $image->resizeXY($width, $height);
    $new_imagename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $width . '_' . $height . '\\2', $imagename);
    $i = 1;
    while (file_exists(NV_ROOTDIR . '/' . $path . '/' . $new_imagename)) {
        $new_imagename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $width . '_' . $height . '_' . $i . '\\2', $imagename);
        $i++;
    }
    $image->save(NV_ROOTDIR . '/' . $path, $new_imagename, 75);
    //$image_info = $image->create_Image_info;
    $image->close();
    echo $new_imagename;
}
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:30,代码来源:createimg.php

示例8: _getThumbnail

 /**
  *
  * @param string $targetFilename
  * @param rectangle $rectangle
  * @return thumbnail
  */
 protected function _getThumbnail($targetFilename, $rectangle)
 {
     $thumbnail = new image($targetFilename);
     $thumbnail->setType($this->getType());
     $thumbnail->fromArea($this, $rectangle);
     $thumbnail->save();
     return $thumbnail;
 }
开发者ID:alexqwert,项目名称:kanon,代码行数:14,代码来源:image.php

示例9: crop_image

 public function crop_image($file, $size = '200')
 {
     $this->using('image');
     $img = new image();
     if ($img->load($file)) {
         $img->thumbnail($size);
         $img->save();
     }
 }
开发者ID:laiello,项目名称:xiv,代码行数:9,代码来源:common.php

示例10: viewsubcat_main

function viewsubcat_main($viewcat, $array_cat)
{
    global $module_name, $module_file, $global_array_cat, $lang_module, $module_config, $module_info, $global_config;
    $xtpl = new XTemplate($viewcat . '.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file);
    $xtpl->assign('LANG', $lang_module);
    $xtpl->assign('TEMPLATE', $global_config['module_theme']);
    // Hien thi cac chu de con
    foreach ($array_cat as $key => $array_row_i) {
        if (isset($array_cat[$key]['content'])) {
            $array_row_i['rss'] = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $module_info['alias']['rss'] . "/" . $array_row_i['alias'];
            $xtpl->assign('CAT', $array_row_i);
            $catid = intval($array_row_i['catid']);
            if ($array_row_i['subcatid'] != '') {
                $exl = 0;
                $arrsubcat_s = explode(',', $array_row_i['subcatid']);
                foreach ($arrsubcat_s as $subcatid_i) {
                    if ($global_array_cat[$subcatid_i]['inhome'] == 1) {
                        $xtpl->clear_autoreset();
                        if ($exl < 3) {
                            $xtpl->assign('SUBCAT', $global_array_cat[$subcatid_i]);
                            $xtpl->parse('main.listcat.subcatloop');
                            $xtpl->set_autoreset();
                        } else {
                            $more = array('title' => $lang_module['more'], 'link' => $global_array_cat[$catid]['link']);
                            $xtpl->assign('MORE', $more);
                            $xtpl->parse('main.listcat.subcatmore');
                            $xtpl->set_autoreset();
                            break;
                        }
                        ++$exl;
                    }
                }
            }
            $a = 0;
            $xtpl->assign('IMGWIDTH', $module_config[$module_name]['homewidth']);
            foreach ($array_cat[$key]['content'] as $array_row_i) {
                $newday = $array_row_i['publtime'] + 86400 * $array_row_i['newday'];
                $array_row_i['publtime'] = nv_date('d/m/Y h:i:s A', $array_row_i['publtime']);
                $array_row_i['hometext'] = nv_clean60($array_row_i['hometext'], 90);
                $array_row_i['title0'] = nv_clean60($array_row_i['title'], 40);
                ++$a;
                if ($a == 1) {
                    $image = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $array_row_i['homeimgfile'];
                    if ($array_row_i['homeimgfile'] != '' and file_exists($image)) {
                        $width = 370;
                        $height = 200;
                        $array_row_i['imghome'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $array_row_i['homeimgfile'];
                        $imginfo = nv_is_image($image);
                        $basename = basename($image);
                        if ($imginfo['width'] > $width or $imginfo['height'] > $height) {
                            $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', $module_name . '_' . $array_row_i['id'] . '_\\1_' . $width . '-' . $height . '\\2', $basename);
                            if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                                $array_row_i['imghome'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                            } else {
                                require_once NV_ROOTDIR . '/includes/class/image.class.php';
                                $_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
                                $_image->cropFromCenter($width, $height);
                                $_image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
                                if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                                    $array_row_i['imghome'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                                }
                            }
                        }
                    }
                    if ($newday >= NV_CURRENTTIME) {
                        $xtpl->parse('main.listcat.newday');
                    }
                    $xtpl->assign('CONTENT', $array_row_i);
                    if ($array_row_i['imghome'] != "") {
                        $xtpl->assign('HOMEIMG', $array_row_i['imghome']);
                        $xtpl->assign('HOMEIMGALT', !empty($array_row_i['homeimgalt']) ? $array_row_i['homeimgalt'] : $array_row_i['title']);
                        $xtpl->parse('main.listcat.image');
                    }
                    if (defined('NV_IS_MODADMIN')) {
                        $xtpl->assign('ADMINLINK', nv_link_edit_page($array_row_i['id']) . " " . nv_link_delete_page($array_row_i['id']));
                        $xtpl->parse('main.listcat.adminlink');
                    }
                } else {
                    if ($newday >= NV_CURRENTTIME) {
                        $xtpl->assign('CLASS', 'icon_new_small');
                    } else {
                        $xtpl->assign('CLASS', 'icon_list');
                    }
                    $array_row_i['title0'] = nv_clean60($array_row_i['title'], 35);
                    $array_row_i['hometext'] = nv_clean60($array_row_i['hometext'], 90);
                    $xtpl->assign('OTHER', $array_row_i);
                    $xtpl->parse('main.listcat.related.loop');
                }
                if ($a > 1) {
                    $xtpl->assign('WCT', 'col-md-8 ');
                } else {
                    $xtpl->assign('WCT', '');
                }
                $xtpl->set_autoreset();
            }
            if ($a > 1) {
                $xtpl->parse('main.listcat.related');
            }
            $xtpl->parse('main.listcat');
        }
//.........这里部分代码省略.........
开发者ID:hongoctrien,项目名称:themes-newszine,代码行数:101,代码来源:theme.php

示例11: elseif

        $upload_logo = NV_ROOTDIR . '/' . $global_config['site_logo'];
    } elseif (file_exists(NV_ROOTDIR . '/images/logo.png')) {
        $upload_logo = NV_ROOTDIR . '/images/logo.png';
    } else {
        die('ERROR#' . $lang_module['notlogo']);
    }
    $config_logo = array();
    $config_logo['x'] = $nv_Request->get_int('x', 'post', 0);
    $config_logo['y'] = $nv_Request->get_int('y', 'post', 0);
    $config_logo['w'] = $nv_Request->get_int('w', 'post', 0);
    $config_logo['h'] = $nv_Request->get_int('h', 'post', 0);
    if ($config_logo['w'] > 0 and $config_logo['h'] > 0) {
        require_once NV_ROOTDIR . '/includes/class/image.class.php';
        $createImage = new image(NV_ROOTDIR . '/' . $path . '/' . $file, NV_MAX_WIDTH, NV_MAX_HEIGHT);
        $createImage->addlogo($upload_logo, '', '', $config_logo);
        $createImage->save(NV_ROOTDIR . '/' . $path, $file);
        $createImage->close();
        if (isset($array_dirname[$path])) {
            if (preg_match('/^' . nv_preg_quote(NV_UPLOADS_DIR) . '\\/(([a-z0-9\\-\\_\\/]+\\/)*([a-z0-9\\-\\_\\.]+)(\\.(gif|jpg|jpeg|png)))$/i', $path . '/' . $file, $m)) {
                @nv_deletefile(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $m[1]);
            }
            $info = nv_getFileInfo($path, $file);
            $did = $array_dirname[$path];
            $db->query("UPDATE " . NV_UPLOAD_GLOBALTABLE . "_file SET filesize=" . $info['filesize'] . ", src='" . $info['src'] . "', srcwidth=" . $info['srcwidth'] . ", srcheight=" . $info['srcheight'] . ", sizes='" . $info['size'] . "', userid=" . $admin_info['userid'] . ", mtime=" . $info['mtime'] . " WHERE did = " . $did . " AND title = '" . $file . "'");
        }
        die('OK#' . basename($file));
    } else {
        die('ERROR#' . $lang_module['notlevel']);
    }
}
die('ERROR#Error Access!!');
开发者ID:lzhao18,项目名称:nukeviet,代码行数:31,代码来源:addlogo.php

示例12: nv_ImageInfo

/**
 * nv_ImageInfo()
 * Function xuat ra cac thong tin ve IMAGE de dua vao HTML (src, width, height).
 * 
 * @param mixed $original_name - duong dan tuyet doi den file goc (bat buoc)
 * @param integer $width - chieu rong xuat ra HTML (neu bang 0 se xuat ra kich thuoc thuc)
 * @param bool $is_create_thumb - Neu chieu rong cua hinh lon hon $width, co the tao thumbnail
 * @param string $thumb_path - neu tao thumbnail thi chi ra thu muc chua file thumbnail nay.
 * @return array('src','width','height')
 */
function nv_ImageInfo($original_name, $width = 0, $is_create_thumb = false, $thumb_path = '')
{
    if (empty($original_name)) {
        return false;
    }
    $original_name = realpath($original_name);
    if (empty($original_name)) {
        return false;
    }
    $original_name = str_replace('\\', '/', $original_name);
    $original_name = rtrim($original_name, "\\/");
    unset($matches);
    if (!preg_match("/^" . nv_preg_quote(NV_ROOTDIR) . "\\/(([a-z0-9\\-\\_\\/]+\\/)*([a-z0-9\\-\\_\\.]+)(\\.(gif|jpg|jpeg|png)))\$/i", $original_name, $matches)) {
        return false;
    }
    $imageinfo = array();
    $size = @getimagesize($original_name);
    if (!$size or !isset($size[0]) or !isset($size[1]) or !$size[0] or !$size[1]) {
        return false;
    }
    $imageinfo['orig_src'] = $imageinfo['src'] = NV_BASE_SITEURL . $matches[1];
    $imageinfo['orig_width'] = $imageinfo['width'] = $size[0];
    $imageinfo['orig_height'] = $imageinfo['height'] = $size[1];
    if ($width) {
        $imageinfo['width'] = $width;
        $imageinfo['height'] = ceil($width * $imageinfo['orig_height'] / $imageinfo['orig_width']);
    }
    if ($is_create_thumb and $width and $imageinfo['orig_width'] > $width) {
        if (empty($thumb_path) or !is_dir($thumb_path) or !is_writeable($thumb_path)) {
            $thumb_path = $matches[2];
        } else {
            $thumb_path = realpath($thumb_path);
            if (empty($thumb_path)) {
                $thumb_path = $matches[2];
            } else {
                $thumb_path = str_replace('\\', '/', $thumb_path);
                unset($matches2);
                if (preg_match("/^" . nv_preg_quote(NV_ROOTDIR) . "([a-z0-9\\-\\_\\/]+)*\$/i", $thumb_path, $matches2)) {
                    $thumb_path = ltrim($matches2[1], "\\/");
                } else {
                    $thumb_path = $matches[2];
                }
            }
        }
        if (!empty($thumb_path) and !preg_match("/\\/\$/", $thumb_path)) {
            $thumb_path = $thumb_path . '/';
        }
        $new_src = $thumb_path . $matches[3] . '_' . $width . $matches[4];
        $is_create = true;
        if (file_exists(NV_ROOTDIR . '/' . $new_src)) {
            $size = @getimagesize(NV_ROOTDIR . '/' . $new_src);
            if ($size and isset($size[0]) and isset($size[1]) and $size[0] and $size[1]) {
                $imageinfo['src'] = NV_BASE_SITEURL . $new_src;
                $imageinfo['width'] = $size[0];
                $imageinfo['height'] = $size[1];
                $is_create = false;
            }
        }
        if ($is_create) {
            include NV_ROOTDIR . "/includes/class/image.class.php";
            $image = new image($original_name, NV_MAX_WIDTH, NV_MAX_HEIGHT);
            $image->resizeXY($width);
            $image->save(NV_ROOTDIR . '/' . $thumb_path, $matches[3] . '_' . $width . $matches[4]);
            $image_info = $image->create_Image_info;
            if (file_exists(NV_ROOTDIR . '/' . $new_src)) {
                $imageinfo['src'] = NV_BASE_SITEURL . $new_src;
                $imageinfo['width'] = $image_info['width'];
                $imageinfo['height'] = $image_info['height'];
            }
        }
    }
    return $imageinfo;
}
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:83,代码来源:filesystem_functions.php

示例13: elseif

 } elseif (!empty($rowcontent['homeimgfile'])) {
     $check_thumb = true;
 }
 $homeimgfile = NV_UPLOADS_REAL_DIR . "/" . $module_name . "/" . $rowcontent['homeimgfile'];
 if ($check_thumb and file_exists($homeimgfile)) {
     require_once NV_ROOTDIR . "/includes/class/image.class.php";
     $basename = basename($homeimgfile);
     $image = new image($homeimgfile, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $thumb_basename = $basename;
     $i = 1;
     while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/thumb/' . $thumb_basename)) {
         $thumb_basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
         $i++;
     }
     $image->resizeXY($module_config[$module_name]['homewidth'], $module_config[$module_name]['homeheight']);
     $image->save(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/thumb', $thumb_basename);
     $image_info = $image->create_Image_info;
     $thumb_name = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/', '', $image_info['src']);
     $block_basename = $basename;
     $i = 1;
     while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/block/' . $block_basename)) {
         $block_basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
         $i++;
     }
     $image->resizeXY($module_config[$module_name]['blockwidth'], $module_config[$module_name]['blockheight']);
     $image->save(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/block', $block_basename);
     $image_info = $image->create_Image_info;
     $block_name = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/', '', $image_info['src']);
     $image->close();
     $rowcontent['homeimgthumb'] = $thumb_name . "|" . $block_name;
 }
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:31,代码来源:content.php

示例14: save

 /**
  * save - saves images to path
  * @param $path string - requires trailing slash '/'
  * @return string name
  */
 public function save($path)
 {
     $this->image->save($path . $this->name);
     return $this->name;
 }
开发者ID:john-ko,项目名称:sharonypark,代码行数:10,代码来源:ImageHandler.php

示例15: view_resize_to_height

 public function view_resize_to_height()
 {
     if ($this->model->is_loaded) {
         $height = intval($this->request['height']);
         if ($height && $height > 0) {
             $children = $this->model->get();
             foreach ($children as $child) {
                 if ($child instanceof \adapt\model && $child->table_name == "image_version") {
                     if ($child->action_resized_to_height == "Yes" && $child->height == $height) {
                         /* Return the child */
                         $asset_id = md5("image_version-" . $child->image_version_id . "-resize_to_height-h" . $height);
                         $if_none_match = "";
                         if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                             $if_none_match = str_replace("\"", "", $_SERVER['HTTP_IF_NONE_MATCH']);
                         }
                         if ($if_none_match == $asset_id) {
                             header('HTTP/1.1 304 Not Modified');
                             header("Cache-Control: public");
                             header("Expires: ");
                             header("Content-Type: ");
                             header("Etag: \"{$asset_id}\"");
                             exit(1);
                         } else {
                             $cal = new \adapt\date($child->date_modified);
                             $cal->goto_months(11);
                             $this->content_type = $child->content_type;
                             header("Cache-Control: private");
                             header("Expires: " . $cal->date('D, d M Y H:i:s O'));
                             $cal->goto_months(-11);
                             header("Last-Modified: " . $cal->date('D, d M Y H:i:s O'));
                             header("Etag: \"{$asset_id}\"");
                             $key = $child->file_key;
                             return $this->file_store->get($key);
                         }
                     }
                 }
             }
             /* We never found a matching child so we are going to create one */
             $image = new image($this->model->file_key);
             if (count($image->errors() == 0)) {
                 /* Resize */
                 $image->resize_to_height($height);
                 if ($key = $image->save()) {
                     /* Create a new image version */
                     $image_version = new model_image_version();
                     $image_version->action_resized_to_height = 'Yes';
                     $image_version->height = $height;
                     $image_version->content_type = $this->model->content_type;
                     $image_version->image_id = $this->model->image_id;
                     $image_version->file_key = $key;
                     $image_version->save();
                     $cal = new \adapt\date($image_version->date_modified);
                     $cal->goto_months(11);
                     $this->content_type = $image_version->content_type;
                     header("Cache-Control: private");
                     header("Expires: " . $cal->date('D, d M Y H:i:s O'));
                     $cal->goto_months(-11);
                     header("Last-Modified: " . $cal->date('D, d M Y H:i:s O'));
                     header("Etag: \"{$asset_id}\"");
                     return $this->file_store->get($key);
                 } else {
                     $this->error(500);
                 }
             } else {
                 $this->error(500);
             }
         } else {
             $this->error(500);
         }
     } else {
         $this->error(404);
     }
 }
开发者ID:mbruton,项目名称:adapt_image,代码行数:73,代码来源:controller_image.php


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