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


PHP image::cropFromLeft方法代码示例

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


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

示例1: zesize_img

function zesize_img($hinhanh)
{
    global $folder, $module, $module_config, $module_name;
    if ($hinhanh) {
        require_once NV_ROOTDIR . "/includes/class/image.class.php";
        $basename = basename($hinhanh);
        $image = new image($hinhanh, NV_MAX_WIDTH, NV_MAX_HEIGHT);
        // Creat new folder
        if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder)) {
            nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module, $folder);
        }
        $name = $basename;
        $i = 1;
        while (file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder . '/' . $name)) {
            $name = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
            $i++;
        }
        $image_info1 = $image->fileinfo;
        $img_w = $module_config[$module_name]['width'];
        $img_h = $module_config[$module_name]['height'];
        $image_info = array();
        $homeimg = "";
        if ($image_info1['width'] / $image_info1['height'] < $img_w / $img_h) {
            $image->resizeXY($img_w, NV_MAX_HEIGHT);
        } else {
            $image->resizeXY(NV_MAX_WIDTH, $img_h);
        }
        $image->cropFromLeft(0, 0, $img_w, $img_h);
        $image->save(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder, $name);
        $image_info = $image->create_Image_info;
        $homeimg = str_replace(NV_UPLOADS_REAL_DIR . '/' . $module . '/', '', $image_info['src']);
        $image->close();
    } else {
        $homeimg = "";
    }
    return $homeimg;
}
开发者ID:anhyeuviolet,项目名称:feednews,代码行数:37,代码来源:global.function.php

示例2: intval

 $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

示例3: htmlspecialchars

}
$file = htmlspecialchars(trim($nv_Request->get_string('file', 'post,get')), ENT_QUOTES);
$file = basename($file);
if (empty($file) or !is_file(NV_ROOTDIR . '/' . $path . '/' . $file)) {
    die('ERROR#' . $lang_module['errorNotSelectFile'] . NV_ROOTDIR . '/' . $path . '/' . $file);
}
if ($nv_Request->isset_request('path', 'post') and $nv_Request->isset_request('x', 'post') and $nv_Request->isset_request('y', 'post')) {
    $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->cropFromLeft($config_logo['x'], $config_logo['y'], $config_logo['w'], $config_logo['h']);
        $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']);
    }
}
开发者ID:lzhao18,项目名称:nukeviet,代码行数:31,代码来源:cropimg.php


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