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


PHP resize_image函数代码示例

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


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

示例1: get_video_prev

function get_video_prev($id, $size)
{
    $size = explode('x', strtolower($size));
    $size[0] = prev_size_c(@$size[0]);
    $size[1] = prev_size_c(@$size[1]);
    if (!$size[1] || !$size[0]) {
        return false;
    }
    $pf = ROOT_PATH . '/tmp/attach_thumb/att-' . $id . '-' . $size[0] . '-' . $size[1] . '.jpg';
    if (file_exists($pf)) {
        return $pf;
    }
    $pm = ROOT_PATH . '/tmp/attach_thumb/att-' . $id . '-video.jpg';
    # Exists master-copy?
    if (!file_exists($pm)) {
        $r = array();
        exec('/usr/local/bin/ffmpeg -i ' . ROOT_PATH . '/uploads/att-' . $id . '.dat -an -ss 5 -r 1 -vframes 1 -s 640x480 -y -f mjpeg ' . $pm, $r);
    }
    if (!file_exists($pm)) {
        return $pm;
    }
    $res = resize_image($pm, $size[0], $size[1]);
    @copy($res, $pf);
    return $res;
}
开发者ID:petrows,项目名称:Upload-service,代码行数:25,代码来源:file.php

示例2: get_thumb_image_url

 /**
  * Returns thumbnail size image url.
  * @since 1.0
  *
  * @return string
  */
 protected function get_thumb_image_url()
 {
     $url = $this->image_url;
     if ($url) {
         return resize_image($url, 120, 120);
     }
     return;
 }
开发者ID:amostajo,项目名称:wordpress-search-typeahead,代码行数:14,代码来源:Post.php

示例3: save_sized_image

 function save_sized_image($original, $key, $size, $folder)
 {
     $file = $folder . "/" . $key . ".jpg";
     $file_path = IMAGES_DIR . "/" . $file;
     resize_image($original, $size, $file_path);
     if (STORAGE_STRATEGY == 's3') {
         $input = S3::inputFile($file_path);
         S3::putObject($input, S3_BUCKET, $file, S3::ACL_PUBLIC_READ);
     }
 }
开发者ID:schlos,项目名称:electionleaflets,代码行数:10,代码来源:image_que.php

示例4: create_thumbnail

function create_thumbnail($filename, $thumbdir = 'sm', $width = 32, $quality = 90)
{
    try {
        $fd = dirname($filename) . '/' . $thumbdir;
        @mkdir($fd);
        $name = basename($filename);
        $thumb = $fd . '/' . $name;
        return resize_image($filename, $thumb, $width, $quality);
    } catch (Exception $e) {
    }
    return false;
}
开发者ID:aodkrisda,项目名称:mayotin,代码行数:12,代码来源:include.php

示例5: upload_song

function upload_song($tempFile, $title = null, $artist = null, $genre = null, $rating = null)
{
    global $db;
    $extension = strtolower(pathinfo($tempFile, PATHINFO_EXTENSION));
    $id = make_song_id($title, $tempFile);
    if ($id === false) {
        return array('success' => false, 'message' => "Duplicate File");
    }
    if (!$title || !$artist) {
        $result = get_song_info($tempFile, $extension);
        if (!$title) {
            $title = $result['title'];
        }
        if (!$artist) {
            $artist = $result['artist'];
        }
    }
    if (!$rating) {
        $rating = 2.5;
    }
    $i = 1;
    $uploadFile = sanitize_file_name($title) . '.' . $extension;
    while (file_exists(__FILES__ . $uploadFile)) {
        $uploadFile = sanitize_file_name($title) . $i . '.' . $extension;
        $i++;
    }
    switch ($extension) {
        case 'txt':
        case 'chopro':
        case 'pdf':
            // NO PROCESSING
            if (!copy($tempFile, __FILES__ . $uploadFile)) {
                return array('success' => false, 'message' => "failed to copy {$tempFile} to {$uploadFile}");
            }
            break;
        case 'jpg':
        case 'jpeg':
        case 'png':
        case 'gif':
            // RESIZE
            resize_image($tempFile, __FILES__ . $uploadFile, $extension, MAX_FILE_W, MAX_FILE_H);
            break;
        default:
            return array('success' => false, 'message' => "file extension '." . $extension . "'not recognized");
            return;
    }
    $query = "INSERT INTO music (songID, location, title, artist, genre, rating, views, uploaded)";
    $query .= " VALUES ( '" . $db->escape($id) . "','" . $db->escape($uploadFile) . "','";
    $query .= $db->escape($title) . "','" . $db->escape($artist) . "','" . $db->escape($genre) . "'," . $db->escape($rating) . ",0," . time() . " )";
    $result = $db->query($query);
    unlink($tempFile);
    return array('success' => true, 'message' => $title . " successfully uploaded!");
}
开发者ID:gschoppe,项目名称:Repertoire,代码行数:53,代码来源:functions-song.php

示例6: process_image

function process_image($dir, $filename)
{
    // Set up the variables
    $i = strrpos($filename, '.');
    $image_name = substr($filename, 0, $i);
    $ext = substr($filename, $i);
    // Set up the read path
    $image_path = $dir . $filename;
    // Set up the write paths
    $image_path_m = $dir . $image_name . '_m' . $ext;
    $image_path_s = $dir . $image_name . '_s' . $ext;
    // Create an image that's a maximum of 400x300 pixels
    resize_image($image_path, $image_path_m, 250, 250);
    // Create a thumbnail image that's a maximum of 100x100 pixels
    resize_image($image_path, $image_path_s, 120, 100);
}
开发者ID:pd00996,项目名称:hunghbpd00996,代码行数:16,代码来源:images.php

示例7: process_image

function process_image($dir, $filename)
{
    // Set up the variables
    $dir = $dir . DIRECTORY_SEPARATOR;
    $i = strrpos($filename, '.');
    $image_name = substr($filename, 0, $i);
    $ext = substr($filename, $i);
    // Set up the read path
    $image_path = $dir . DIRECTORY_SEPARATOR . $filename;
    // Set up the write paths
    $image_path_400 = $dir . $image_name . '_400' . $ext;
    $image_path_100 = $dir . $image_name . '_100' . $ext;
    // Create an image that's a maximum of 400x300 pixels
    resize_image($image_path, $image_path_400, 400, 300);
    // Create a thumbnail image that's a maximum of 100x100 pixels
    resize_image($image_path, $image_path_100, 100, 100);
}
开发者ID:Garaix-Davy,项目名称:cit336,代码行数:17,代码来源:image_util.php

示例8: save_image

 private function save_image($temp_file)
 {
     //generate a random ID for this image
     $file_id = md5(uniqid(rand(), true));
     array_push($this->image_ids, $file_id);
     //copy original
     $original_file_name = IMAGES_DIR . "/original/" . $file_id . ".jpg";
     $moved = move_uploaded_file($temp_file, $original_file_name);
     if (!$moved) {
         $this->add_warning("Sorry something went wrong saving your image");
     } else {
         //save large
         resize_image($original_file_name, IMAGE_LARGE_SIZE, IMAGES_DIR . "/large/" . $file_id . ".jpg");
         //save medium
         resize_image($original_file_name, IMAGE_MEDIUM_SIZE, IMAGES_DIR . "/medium/" . $file_id . ".jpg");
         //save thumbnail
         resize_image($original_file_name, IMAGE_THUMBNAIL_SIZE, IMAGES_DIR . "/thumbnail/" . $file_id . ".jpg");
     }
 }
开发者ID:GetUp,项目名称:Election-Leaflet-Project-Australia,代码行数:19,代码来源:addupload.php

示例9: cacheImages

 public function cacheImages($images)
 {
     foreach ($images as $key => $url) {
         if (file_exists($this->getImagesCachePath($url))) {
             # exclude images in already in cache
             unset($images[$key]);
         }
     }
     if (empty($images)) {
         return true;
     }
     $mh = curl_multi_init();
     $cHandlers = array();
     foreach ($images as $url) {
         $cHandlers[$url] = curl_init();
         curl_setopt($cHandlers[$url], CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($cHandlers[$url], CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($cHandlers[$url], CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($cHandlers[$url], CURLOPT_URL, $url);
         curl_setopt($cHandlers[$url], CURLOPT_RETURNTRANSFER, true);
         curl_setopt($cHandlers[$url], CURLOPT_TIMEOUT, 30);
         curl_multi_add_handle($mh, $cHandlers[$url]);
     }
     $running = NULL;
     do {
         usleep(10000);
         curl_multi_exec($mh, $running);
     } while ($running > 0);
     foreach ($cHandlers as $url => $ch) {
         $imgData = curl_multi_getcontent($ch);
         curl_multi_remove_handle($mh, $ch);
         $cachePath = $this->getImagesCachePath($url);
         $pathinfo = pathinfo($cachePath);
         $tmpfile = cfg()->tmpDir . "/" . uniqid() . "." . $pathinfo['extension'];
         if (file_put_contents($tmpfile, $imgData)) {
             resize_image($tmpfile, $cachePath, cfg()->ali->cache->images->resize);
             unlink($tmpfile);
         }
     }
 }
开发者ID:avramishin,项目名称:alishop,代码行数:40,代码来源:AliExpressApi.php

示例10: get_cached_thumbnail_link

function get_cached_thumbnail_link($width, $link, $forced = false)
{
    global $thumbnail_directory;
    // $link をローカルファイルのパスに変換
    $src = link_to_path($link);
    // $width, $srcをチェック
    if (!preg_match("/^\\d{1,4}\$/", $width) || !file_exists($src)) {
        // 不正なら空文字列を返す
        return "";
    }
    //thumbnailのパスを決める
    $thumbnail_path = thumbnail_path($width, $src);
    if (!$forced && file_exists($thumbnail_path) && stat($thumbnail_path)["mtime"] > stat($src)["mtime"]) {
        // $forced=falseであり、かつ、
        //  キャッシュされているサムネイルが既に存在し、かつ、
        //   それが新しければ何もしない
    } else {
        // 上記以外の場合、キャッシュを生成する
        resize_image($width, $src, $thumbnail_path);
    }
    // キャッシュへのhtmlリンクを返す
    return path_to_link($thumbnail_path);
}
开发者ID:yoshinaga-t,项目名称:club_ace,代码行数:23,代码来源:html_component.php

示例11: upload_file

 function upload_file()
 {
     if (!isset($this->file) || is_null($this->file['tmp_name']) || $this->file['name'] == '') {
         //Check File //Chequea sl archivo
         //$this->file['name']=$defecto;// = "Archivo no fue subido";
         $this->ErrorMsg = "Archivo no fue subido";
         return false;
     }
     if ($this->file['size'] > $this->maxsize) {
         //Check Size
         $this->ErrorMsg = "El Archivo Excede el Tamaño permitido de {$this->maxsize} bytes";
         return false;
     }
     if (count($this->allowtypes) > 0 && !in_array($this->file['type'], $this->allowtypes) || count($this->deniedtypes) > 0 && in_array($this->file['type'], $this->deniedtypes)) {
         //Check Type //Chequea el tipo de archivo
         $this->ErrorMsg = "Tipo de Archivo '." . file_extension($this->file['name']) . " -- {$this->file['type']}' No Permitido.";
         return false;
     }
     if (!$this->newfile) {
         $this->newfile = substr(basename($this->file['name']), 0, strrpos($this->file['name'], '.'));
     }
     //No new name specified, default to old name
     $uploaddirtemp = upload_dir($this->uploaddir);
     //Create Upload Dir
     move_uploaded_file($this->file['tmp_name'], $uploaddirtemp . $this->newfile . "." . file_extension($this->file['name']));
     //Move Uploaded File
     if ($maxwidth == "" && ($maxheight = "")) {
         //No need to resize the image, user did not specify to reszie
         $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
         return true;
     }
     //User is going to resize the image
     resize_image("." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']), $this->maxwidth, $this->maxheight, $this->scale, $this->relscale, $this->jpegquality);
     $this->final = "." . $this->uploaddir . $this->newfile . "." . file_extension($this->file['name']);
     return true;
     //Hooray!
 }
开发者ID:nelson1212,项目名称:xffdddsdds,代码行数:37,代码来源:image_upload_and_resize.php

示例12: array

         $submitnews_filearray = array();
         foreach ($uploaded as $c => $v) {
             if (varset($uploaded[$c]['error'], 0) != 0) {
                 $submitnews_error = TRUE;
                 $message = handle_upload_messages($uploaded);
             } else {
                 if (isset($uploaded[$c]['name']) && isset($uploaded[$c]['type']) && isset($uploaded[$c]['size'])) {
                     $filename = $uploaded[$c]['name'];
                     $filetype = $uploaded[$c]['type'];
                     $filesize = $uploaded[$c]['size'];
                     $fileext = substr(strrchr($filename, "."), 1);
                     $today = getdate();
                     $submitnews_file = USERID . "_" . $today[0] . "_" . $c . "_" . str_replace(" ", "_", substr($submitnews_title, 0, 6)) . "." . $fileext;
                     if (is_numeric($pref['subnews_resize']) && $pref['subnews_resize'] > 30 && $pref['subnews_resize'] < 5000) {
                         require_once e_HANDLER . 'resize_handler.php';
                         if (!resize_image(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file, $pref['subnews_resize'])) {
                             rename(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file);
                         }
                     } elseif ($filename) {
                         rename(e_UPLOAD . $filename, e_UPLOAD . $submitnews_file);
                     }
                 }
             }
             if ($filename && file_exists(e_UPLOAD . $submitnews_file)) {
                 $submitnews_filearray[] = $submitnews_file;
             }
         }
     }
 }
 if ($submitnews_error === FALSE) {
     $sql->insert("submitnews", "0, '{$submitnews_user}', '{$submitnews_email}', '{$submitnews_title}', '" . intval($_POST['cat_id']) . "', '{$submitnews_item}', '" . time() . "', '{$ip}', '0', '" . implode(',', $submitnews_filearray) . "' ");
开发者ID:armpit,项目名称:e107,代码行数:31,代码来源:submitnews.php

示例13: cpg_die

         cpg_die(ERROR, $lang_db_input_php['err_invalid_img'], __FILE__, __LINE__, true);
         // JPEG and PNG only are allowed with GD
         //} elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($CONFIG['thumb_method'] == 'gd1' || $CONFIG['thumb_method'] == 'gd2')) {
     } elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && $CONFIG['GIF_support'] == 0) {
         @unlink($uploaded_pic);
         cpg_die(ERROR, $lang_errors['gd_file_type_err'], __FILE__, __LINE__, true);
         // *** NOT NEEDED CHECK DONE BY 'is_image'
         // Check image type is among those allowed for ImageMagick
         //} elseif (!stristr($CONFIG['allowed_img_types'], $IMG_TYPES[$imginfo[2]]) && $CONFIG['thumb_method'] == 'im') {
         //@unlink($uploaded_pic);
         //cpg_die(ERROR, sprintf($lang_db_input_php['allowed_img_types'], $CONFIG['allowed_img_types']), __FILE__, __LINE__);
         // Check that picture size (in pixels) is lower than the maximum allowed
     } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
         if (USER_IS_ADMIN && $CONFIG['auto_resize'] == 1 || !USER_IS_ADMIN && $CONFIG['auto_resize'] > 0) {
             //resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $imginfo[0] > $CONFIG['max_upl_width_height'] ? 'wd' : 'ht');
             resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
         } else {
             @unlink($uploaded_pic);
             cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']), __FILE__, __LINE__);
         }
     }
     // Image is ok
 }
 // Upload is ok
 // Create thumbnail and internediate image and add the image into the DB
 $result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, (int) $_POST['width'], (int) $_POST['height']);
 if (!$result) {
     @unlink($uploaded_pic);
     cpg_die(CRITICAL_ERROR, sprintf($lang_db_input_php['err_insert_pic'], $uploaded_pic) . '<br /><br />' . $ERROR, __FILE__, __LINE__, true);
 } elseif ($PIC_NEED_APPROVAL) {
     pageheader($lang_info);
开发者ID:alencarmo,项目名称:OCF,代码行数:31,代码来源:db_input.php

示例14: dirname

<?php

$dir = dirname(__FILE__);
//echo $dir . "<br>";
$folders = scandir($dir);
foreach ($folders as $categorias) {
    //echo $categorias . "<br>";
    if ($categorias != "." && $categorias != ".." && $categorias != "index.php" && $categorias != "thumb.jpg" && $categorias != "all-thumb.gif" && $categorias != "cs-close.png") {
        $cat = $dir . "/" . $categorias;
        //echo $cat."<br/>";
        $list = scandir($cat);
        //create thumbs
        createThumbs($dir . "/" . $categorias . "", $dir . "/" . $categorias . "/thumbs", 75);
        //reducir
        resize_image($dir . "/" . $categorias . "", $dir . "/" . $categorias . "", 650);
        /*foreach ( $list as $imagen ) {
        			if ($imagen != "." && $imagen != ".." && $imagen != "index.php" && $imagen != "thumb.jpg") {
        				// echo $imagen;
        				//echo $dir . "/" . $categorias."/".$imagen."<br/>";				
        				//echo "se crearon los archivos.<br/>";
        			}
        		}*/
    }
}
function createThumbs($pathToImages, $pathToThumbs, $thumbWidth)
{
    // open the directory
    $dir = opendir($pathToImages);
    if (!is_dir($pathToThumbs)) {
        echo "se creo {$pathToThumbs}<br/>";
        if (!mkdir($pathToThumbs, 0777, true)) {
开发者ID:tineo,项目名称:webapoyopublicitario,代码行数:31,代码来源:index.php

示例15: error_log

$ds = DIRECTORY_SEPARATOR;
//1
$storeFolder = 'uploads';
//2
$campaign_id = $_POST['campaign_id'];
if (!empty($_FILES)) {
    $tempFile = $_FILES['file']['tmp_name'];
    //3
    error_log($tempFile, 3, 'pic_bug.txt');
    $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
    //4
    error_log("-------", 3, 'pic_bug.txt');
    $targetFile = $targetPath . $_FILES['file']['name'];
    //5
    error_log($targetFile, 3, 'pic_bug.txt');
    $img = resize_image($tempFile, 800, 800);
    $fakepath = "http://localhost:8888/carvertise/gallery/admin/uploads/" . $_FILES['file']['name'];
    $carvertisepath = "http://52.23.43.247/gallery/admin/uploads/" . $_FILES['file']['name'];
    if (!imagejpeg($img, 'uploads/' . $_FILES['file']['name'])) {
        error_log("imagejpeg", 3, 'pic_bug.txt');
        echo "Failed to save the cropped image file";
    }
    //move_uploaded_file($img,$targetFile); //6
    $query = "INSERT INTO picture (campaign_id,url) VALUES ('{$campaign_id}','{$carvertisepath}')";
    if (mysqli_query($conn, $query)) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }
}
function resize_image($file, $w, $h, $crop = FALSE)
开发者ID:weihetian,项目名称:gallery,代码行数:31,代码来源:upload.php


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