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


PHP image::resizeXY方法代码示例

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


在下文中一共展示了image::resizeXY方法的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: 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

示例3: 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

示例4: resizeimg

function resizeimg($folder, $linkanh)
{
    global $global_config, $module, $module_name, $module_config;
    require_once NV_ROOTDIR . "/includes/class/image.class.php";
    $basename = basename($linkanh);
    $i = 1;
    while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_config[$module_name]['module'] . '/' . $folder . '/' . $basename)) {
        $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
        $i++;
    }
    $image = new image($linkanh);
    $image_info1 = $image->fileinfo;
    if ($image_info1['width'] > $module_config[$module_name]['bodyimg']) {
        $image->resizeXY($module_config[$module_name]['bodyimg'], NV_MAX_HEIGHT);
    }
    $thumb_basename = $basename;
    $image->save(NV_UPLOADS_REAL_DIR . '/' . $module_config[$module_name]['module'] . '/' . $folder, $thumb_basename);
    $image_info = $image->create_Image_info;
    $img = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module_config[$module_name]['module'] . '/', '', $image_info['src']);
    $image->close();
    return $img;
}
开发者ID:anhyeuviolet,项目名称:feednews,代码行数:22,代码来源:global.function.php

示例5: die

if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$path = nv_check_path_upload($nv_Request->get_string('path', 'post'));
$check_allow_upload_dir = nv_check_allow_upload_dir($path);
if (!isset($check_allow_upload_dir['create_file'])) {
    die('ERROR_' . $lang_module['notlevel']);
}
$width = $nv_Request->get_int('width', 'post');
$height = $nv_Request->get_int('height', 'post');
$imagename = htmlspecialchars(trim($nv_Request->get_string('img', 'post')), ENT_QUOTES);
$imagename = basename($imagename);
$file = preg_replace('/^(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $width . '_' . $height . '\\2', $imagename);
$i = 1;
while (file_exists(NV_ROOTDIR . '/' . $path . '/' . $file)) {
    $file = preg_replace('/^(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $width . '_' . $height . '_' . $i . '\\2', $imagename);
    ++$i;
}
$createImage = new image(NV_ROOTDIR . '/' . $path . '/' . $imagename, NV_MAX_WIDTH, NV_MAX_HEIGHT);
$createImage->resizeXY($width, $height);
$createImage->save(NV_ROOTDIR . '/' . $path, $file, 75);
$createImage->close();
if (isset($array_dirname[$path])) {
    $did = $array_dirname[$path];
    $info = nv_getFileInfo($path, $file);
    $info['userid'] = $admin_info['userid'];
    $db->query("INSERT INTO " . NV_UPLOAD_GLOBALTABLE . "_file\n\t\t\t\t\t\t\t(name, ext, type, filesize, src, srcwidth, srcheight, sizes, userid, mtime, did, title) VALUES\n\t\t\t\t\t\t\t('" . $info['name'] . "', '" . $info['ext'] . "', '" . $info['type'] . "', " . $info['filesize'] . ", '" . $info['src'] . "', " . $info['srcwidth'] . ", " . $info['srcheight'] . ", '" . $info['size'] . "', " . $info['userid'] . ", " . $info['mtime'] . ", " . $did . ", '" . $file . "')");
}
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['upload_createimage'], $path . '/' . $file, $admin_info['userid']);
echo $file;
exit;
开发者ID:anhtunguyen,项目名称:vietnamguide,代码行数:31,代码来源:createimg.php

示例6: elseif

         $array['thumbnail'] = $thumbnail;
     }
 } elseif (!empty($array['image'])) {
     $check_thumb = true;
 }
 if ($check_thumb and is_file(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . "/" . $module_name . "/topics/" . $array['image'])) {
     require_once NV_ROOTDIR . "/includes/class/image.class.php";
     $basename = basename($array['image']);
     $image = new image(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . "/" . $module_name . "/topics/" . $array['image'], NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $thumb_basename = $basename;
     $i = 1;
     while (is_file(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module_name . '/topics/' . $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_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module_name . '/topics', $thumb_basename);
     $image_info = $image->create_Image_info;
     $array['thumbnail'] = str_replace(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module_name . '/topics/', '', $image_info['src']);
 }
 $array['alias'] = $array['alias'] == "" ? change_alias($array['title']) : change_alias($array['alias']);
 if (empty($array['title'])) {
     $error = $lang_module['topics_error_title'];
 } elseif ($array['topicid'] == 0) {
     list($weight) = $db->sql_fetchrow($db->sql_query("SELECT max(`weight`) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_topics`"));
     $weight = intval($weight) + 1;
     $query = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_topics` (`topicid`, `title`, `alias`, `description`, `image`, `thumbnail`, `weight`, `keywords`, `add_time`, `edit_time`) VALUES (NULL, " . $db->dbescape($array['title']) . ", " . $db->dbescape($array['alias']) . ", " . $db->dbescape($array['description']) . ", " . $db->dbescape($array['image']) . ", " . $db->dbescape($array['thumbnail']) . ", " . $db->dbescape($weight) . ", " . $db->dbescape($array['keywords']) . ", UNIX_TIMESTAMP( ), UNIX_TIMESTAMP( ))";
     if ($db->sql_query_insert_id($query)) {
         nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_topic', " ", $admin_info['userid']);
         $db->sql_freeresult();
         Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "");
开发者ID:atarubi,项目名称:nuke-viet,代码行数:31,代码来源:topics.php

示例7: 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

示例8: image

         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);
             $thumb_width = $width;
             $thumb_height = $height;
             $maxwh = max($thumb_width, $thumb_height);
             if ($image->fileinfo['width'] > $image->fileinfo['height']) {
                 $width = 0;
                 $height = $maxwh;
             } else {
                 $width = $maxwh;
                 $height = 0;
             }
             $image->resizeXY($width, $height);
             $image->cropFromCenter($thumb_width, $thumb_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]['show_no_image'];
 } else {
     $row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no_image.gif';
 }
 $array_data[$row['id']] = $row;
开发者ID:hoangvtien,项目名称:module-event,代码行数:31,代码来源:main.php

示例9: upload

 if (isset($_FILES['avatar']) and is_uploaded_file($_FILES['avatar']['tmp_name'])) {
     @(require_once NV_ROOTDIR . "/includes/class/upload.class.php");
     $upload = new upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $upload_info = $upload->save_file($_FILES['avatar'], NV_UPLOADS_REAL_DIR . '/' . $module_name, false);
     @unlink($_FILES['avatar']['tmp_name']);
     if (empty($upload_info['error'])) {
         @chmod($upload_info['name'], 0644);
         if (!empty($array_data['photo']) and is_file(NV_ROOTDIR . '/' . $array_data['photo'])) {
             @nv_deletefile(NV_ROOTDIR . '/' . $array_data['photo']);
         }
         $image = $upload_info['name'];
         $basename = $upload_info['basename'];
         $imginfo = nv_is_image($image);
         $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $user_info['userid'] . '-80-80\\2', $basename);
         $_image = new image($image, 80, 80);
         $_image->resizeXY(80, 80);
         $_image->save(NV_UPLOADS_REAL_DIR . '/' . $module_name, $basename);
         if (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $basename)) {
             $file_name = NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $basename;
             //@chmod($file_name, 0644);
             $file_name = str_replace(NV_ROOTDIR . "/", "", $file_name);
             @nv_deletefile($upload_info['name']);
         }
         $sql = "UPDATE `" . NV_USERS_GLOBALTABLE . "` SET `photo`=" . $db->dbescape_string($file_name) . " WHERE `userid`=" . $user_info['userid'];
         $db->sql_query($sql);
     } else {
         $error[] = $lang_module['avata'];
     }
 }
 $info = $lang_module['editinfo_ok'];
 $sec = 3;
开发者ID:atarubi,项目名称:nuke-viet,代码行数:31,代码来源:editinfo.php

示例10: nv_get_viewImage

function nv_get_viewImage($fileName)
{
    global $array_thumb_config;
    if (preg_match('/^' . nv_preg_quote(NV_UPLOADS_DIR) . '\\/(([a-z0-9\\-\\_\\/]+\\/)*([a-z0-9\\-\\_\\.]+)(\\.(gif|jpg|jpeg|png)))$/i', $fileName, $m)) {
        $viewFile = NV_FILES_DIR . '/' . $m[1];
        if (file_exists(NV_ROOTDIR . '/' . $viewFile)) {
            $size = @getimagesize(NV_ROOTDIR . '/' . $viewFile);
            return array($viewFile, $size[0], $size[1]);
        } else {
            $m[2] = rtrim($m[2], '/');
            if (isset($array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]])) {
                $thumb_config = $array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]];
            } else {
                $thumb_config = $array_thumb_config[''];
                $_arr_path = explode('/', NV_UPLOADS_DIR . '/' . $m[2]);
                while (sizeof($_arr_path) > 1) {
                    array_pop($_arr_path);
                    $_path = implode('/', $_arr_path);
                    if (isset($array_thumb_config[$_path])) {
                        $thumb_config = $array_thumb_config[$_path];
                        break;
                    }
                }
            }
            $viewDir = NV_FILES_DIR;
            if (!empty($m[2])) {
                if (!is_dir(NV_ROOTDIR . '/' . $m[2])) {
                    $e = explode('/', $m[2]);
                    $cp = NV_FILES_DIR;
                    foreach ($e as $p) {
                        if (is_dir(NV_ROOTDIR . '/' . $cp . '/' . $p)) {
                            $viewDir .= '/' . $p;
                        } else {
                            $mk = nv_mkdir(NV_ROOTDIR . '/' . $cp, $p);
                            if ($mk[0] > 0) {
                                $viewDir .= '/' . $p;
                            }
                        }
                        $cp .= '/' . $p;
                    }
                }
            }
            $image = new image(NV_ROOTDIR . '/' . $fileName, NV_MAX_WIDTH, NV_MAX_HEIGHT);
            if ($thumb_config['thumb_type'] == 4) {
                $thumb_width = $thumb_config['thumb_width'];
                $thumb_height = $thumb_config['thumb_height'];
                $maxwh = max($thumb_width, $thumb_height);
                if ($image->fileinfo['width'] > $image->fileinfo['height']) {
                    $thumb_config['thumb_width'] = 0;
                    $thumb_config['thumb_height'] = $maxwh;
                } else {
                    $thumb_config['thumb_width'] = $maxwh;
                    $thumb_config['thumb_height'] = 0;
                }
            }
            $image->resizeXY($thumb_config['thumb_width'], $thumb_config['thumb_height']);
            if ($thumb_config['thumb_type'] == 4) {
                $image->cropFromCenter($thumb_width, $thumb_height);
            }
            $image->save(NV_ROOTDIR . '/' . $viewDir, $m[3] . $m[4], $thumb_config['thumb_quality']);
            $create_Image_info = $image->create_Image_info;
            $error = $image->error;
            $image->close();
            if (empty($error)) {
                return array($viewDir . '/' . basename($create_Image_info['src']), $create_Image_info['width'], $create_Image_info['height']);
            }
        }
    } else {
        $size = @getimagesize(NV_ROOTDIR . '/' . $fileName);
        return array($viewFile, $size[0], $size[1]);
    }
    return false;
}
开发者ID:hongoctrien,项目名称:module_c34to40,代码行数:73,代码来源:news.php

示例11: nv_get_viewImage

/**
 * nv_get_viewImage()
 *
 * @param mixed $fileName
 * @param integer $w
 * @param integer $h
 * @return
 */
function nv_get_viewImage($fileName, $w = 80, $h = 80)
{
    $ext = nv_getextension($fileName);
    $md5_view_image = md5($fileName);
    $viewDir = NV_FILES_DIR . '/images';
    $viewFile = $viewDir . '/' . $md5_view_image . '.' . $ext;
    if (file_exists(NV_ROOTDIR . '/' . $viewFile)) {
        $size = @getimagesize(NV_ROOTDIR . '/' . $viewFile);
        return array($viewFile, $size[0], $size[1]);
    }
    include_once NV_ROOTDIR . "/includes/class/image.class.php";
    $image = new image(NV_ROOTDIR . '/' . $fileName, NV_MAX_WIDTH, NV_MAX_HEIGHT);
    $image->resizeXY($w, $h);
    $image->save(NV_ROOTDIR . '/' . $viewDir, $md5_view_image, 75);
    $create_Image_info = $image->create_Image_info;
    $error = $image->error;
    $image->close();
    if (empty($error)) {
        return array($viewDir . '/' . basename($create_Image_info['src']), $create_Image_info['width'], $create_Image_info['height']);
    }
    return false;
}
开发者ID:atarubi,项目名称:nuke-viet,代码行数:30,代码来源:functions.php

示例12: XTemplate

 function nv_news_block_newscenter($block_config)
 {
     global $module_data, $module_name, $module_file, $module_upload, $global_array_cat, $global_config, $lang_module, $db, $module_config, $module_info;
     $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);
     $list = array_values($list);
     if (!empty($list)) {
         $xtpl = new XTemplate('block_newscenter.tpl', NV_ROOTDIR . '/themes/' . $module_info['template'] . '/modules/' . $module_file);
         $xtpl->assign('lang', $lang_module);
         $xtpl->assign('TOOLTIP_POSITION', $block_config['tooltip_position']);
         foreach ($list as $i => $row) {
             $row['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $global_array_cat[$row['catid']]['alias'] . '/' . $row['alias'] . '-' . $row['id'] . $global_config['rewrite_exturl'];
             $row['hometext'] = nv_clean60(strip_tags($row['hometext']), 360);
             $row['titleclean60'] = nv_clean60($row['title'], 60);
             if ($i == 0) {
                 $width = isset($block_config['width']) ? $block_config['width'] : 400;
                 $height = isset($block_config['height']) ? $block_config['height'] : 268;
                 if ($row['homeimgfile'] != '' and ($imginfo = nv_is_image(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $row['homeimgfile'])) != array()) {
                     $image = NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $row['homeimgfile'];
                     if ($imginfo['width'] <= $width and $imginfo['height'] <= $height) {
                         $row['imgsource'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $row['homeimgfile'];
                         $row['width'] = $imginfo['width'];
                     } else {
                         $basename = preg_replace('/(.*)(\\.[a-z]+)$/i', $module_name . '_' . $row['id'] . '_\\1_' . $width . '-' . $height . '\\2', basename($image));
                         if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename)) {
                             $imginfo = nv_is_image(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename);
                             $row['imgsource'] = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                             $row['width'] = $imginfo['width'];
                         } else {
                             $_image = new image($image, NV_MAX_WIDTH, NV_MAX_HEIGHT);
                             $_image->resizeXY($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;
                                 $row['width'] = $_image->create_Image_info['width'];
                             }
                         }
                     }
                 } elseif (nv_is_url($row['homeimgfile'])) {
                     $row['imgsource'] = $row['homeimgfile'];
                     $row['width'] = $width;
                 } elseif (!empty($module_config[$module_name]['show_no_image'])) {
                     $row['imgsource'] = NV_BASE_SITEURL . $module_config[$module_name]['show_no_image'];
                     $row['width'] = $width;
                 } else {
                     $row['imgsource'] = NV_BASE_SITEURL . 'themes/' . $global_config['site_theme'] . '/images/no_image.gif';
                     $row['width'] = $width;
                 }
                 $xtpl->assign('main', $row);
             } else {
                 if ($row['homeimgthumb'] == 1) {
                     $row['imgsource'] = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $row['homeimgfile'];
                 } elseif ($row['homeimgthumb'] == 2) {
                     $row['imgsource'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $row['homeimgfile'];
                 } elseif ($row['homeimgthumb'] == 3) {
                     $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.gif';
                 }
                 $row['hometext'] = nv_clean60($row['hometext'], $block_config['tooltip_length'], true);
                 $xtpl->assign('othernews', $row);
                 if (!$block_config['showtooltip']) {
                     $xtpl->assign('TITLE', 'title="' . $row['title'] . '"');
                 }
                 if ($block_config['showtooltip']) {
                     $xtpl->parse('main.othernews.tooltip');
                 }
                 $xtpl->parse('main.othernews');
             }
         }
         $xtpl->parse('main');
         return $xtpl->text('main');
     }
 }
开发者ID:anhtunguyen,项目名称:vietnamguide,代码行数:76,代码来源:module.block_newscenter.php

示例13: upload

 }
 require_once NV_ROOTDIR . '/includes/class/upload.class.php';
 $upload = new upload($allow_files_type, $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
 if (isset($_FILES['upload']['tmp_name']) and is_uploaded_file($_FILES['upload']['tmp_name'])) {
     $upload_info = $upload->save_file($_FILES['upload'], NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']);
 } else {
     $urlfile = rawurldecode(trim($nv_Request->get_string('fileurl', 'post')));
     $upload_info = $upload->save_urlfile($urlfile, NV_ROOTDIR . '/' . $path, false, $global_config['nv_auto_resize']);
 }
 if (!empty($upload_info['error'])) {
     $error = $upload_info['error'];
 } elseif (preg_match('#image\\/[x\\-]*([a-z]+)#', $upload_info['mime'])) {
     if ($global_config['nv_auto_resize'] and ($upload_info['img_info'][0] > NV_MAX_WIDTH or $upload_info['img_info'][0] > NV_MAX_HEIGHT)) {
         require_once NV_ROOTDIR . '/includes/class/image.class.php';
         $createImage = new image(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename'], $upload_info['img_info'][0], $upload_info['img_info'][1]);
         $createImage->resizeXY(NV_MAX_WIDTH, NV_MAX_HEIGHT);
         $createImage->save(NV_ROOTDIR . '/' . $path, $upload_info['basename'], 90);
         $createImage->close();
         $info = $createImage->create_Image_info;
         $upload_info['img_info'][0] = $info['width'];
         $upload_info['img_info'][1] = $info['height'];
         $upload_info['size'] = filesize(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename']);
     }
     if ($upload_info['size'] > NV_UPLOAD_MAX_FILESIZE) {
         nv_deletefile(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename']);
         $error = sprintf($lang_global['error_upload_max_user_size'], NV_UPLOAD_MAX_FILESIZE);
     } else {
         if ($upload_info['img_info'][0] > NV_MAX_WIDTH or $upload_info['img_info'][1] > NV_MAX_HEIGHT) {
             nv_deletefile(NV_ROOTDIR . '/' . $path . '/' . $upload_info['basename']);
             if ($upload_info['img_info'][0] > NV_MAX_WIDTH) {
                 $error = sprintf($lang_global['error_upload_image_width'], NV_MAX_WIDTH);
开发者ID:lzhao18,项目名称:nukeviet,代码行数:31,代码来源:upload.php

示例14: strlen

 $data['path'] = filter_text_input('pic_path', 'post', '', 0);
 $data['v_path'] = filter_text_input('v_path', 'post', '', 0);
 $data['description'] = filter_text_textarea('description', '', NV_ALLOWED_HTML_TAGS);
 $data['is_show'] = filter_text_input('is_show', 'post', '0', 0);
 if (!empty($data['v_path']) and file_exists(NV_DOCUMENT_ROOT . $data['v_path'])) {
     $lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name);
     $data['v_path'] = substr($data['v_path'], $lu);
 } elseif (!nv_is_url($data['v_path']) and !empty($data['v_path'])) {
     $data['v_path'] = "";
 }
 if (!empty($data['path']) and file_exists(NV_DOCUMENT_ROOT . $data['path'])) {
     $homeimgfile = NV_DOCUMENT_ROOT . $data['path'];
     require_once NV_ROOTDIR . "/includes/class/image.class.php";
     $basename = basename($homeimgfile);
     $image = new image($homeimgfile, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $image->resizeXY($max_x, $max_y);
     $image->save(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/thumb', $basename);
     $image_info = $image->create_Image_info;
     $image->close();
     $thumb_name = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/', '', $image_info['src']);
     $lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name);
     $data['path'] = substr($data['path'], $lu);
 } elseif (!nv_is_url($data['path']) and !empty($data['path'])) {
     $data['path'] = "";
 }
 if ($data['albumid'] > 0) {
     if (empty($data['name'])) {
         $error = $lang_module['err_null_name'];
     } else {
         if (empty($data['v_path'])) {
             $error = $lang_module['err_null_path'];
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:31,代码来源:add_img.php

示例15: intval

 $array['avatar_width'] = intval($array['x2'] - $array['x1']);
 $array['avatar_height'] = intval($array['y2'] - $array['y1']);
 if (sizeof(array_filter(array($array['x1'], $array['y1'], $array['x2'], $array['y2'], $array['w'], $array['h']))) < 4 or $array['avatar_width'] < $global_config['avatar_width'] or $array['avatar_height'] < $global_config['avatar_height']) {
     $array['error'] = $lang_module['avata_error_data'];
 } else {
     $upload = new upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     // Storage in temp dir
     $upload_info = $upload->save_file($_FILES['image_file'], NV_ROOTDIR . '/' . NV_TEMP_DIR, false);
     // Delete upload tmp
     @unlink($_FILES['image_file']['tmp_name']);
     if (empty($upload_info['error'])) {
         $basename = $upload_info['basename'];
         $basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . nv_genpass(8) . "_" . $user_info['userid'] . '\\2', $basename);
         $image = new image($upload_info['name'], NV_MAX_WIDTH, NV_MAX_HEIGHT);
         // Resize image, crop image
         $image->resizeXY($array['w'], $array['h']);
         $image->cropFromLeft($array['x1'], $array['y1'], $array['avatar_width'], $array['avatar_height']);
         $image->resizeXY($global_config['avatar_width'], $global_config['avatar_height']);
         // Save new image
         $image->save(NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename);
         $image->close();
         if (file_exists($image->create_Image_info['src'])) {
             $array['success'] = true;
             $array['filename'] = str_replace(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/', '', $image->create_Image_info['src']);
         } else {
             $array['error'] = $lang_module['avata_error_save'];
         }
         @nv_deletefile($upload_info['name']);
     } else {
         $array['error'] = $upload_info['error'];
     }
开发者ID:anhtunguyen,项目名称:vietnamguide,代码行数:31,代码来源:avatar.php


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