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


PHP ImageCopyResampled函数代码示例

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


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

示例1: kicsinyites

function kicsinyites($forras, $kimenet, $max)
{
    if (!isset($max)) {
        $max = 120;
    }
    # maximum size of 1 side of the picture.
    $src_img = ImagecreateFromJpeg($forras);
    $oh = imagesy($src_img);
    # original height
    $ow = imagesx($src_img);
    # original width
    $new_h = $oh;
    $new_w = $ow;
    if ($oh > $max || $ow > $max) {
        $r = $oh / $ow;
        $new_h = $oh > $ow ? $max : $max * $r;
        $new_w = $new_h / $r;
    }
    // note TrueColor does 256 and not.. 8
    $dst_img = ImageCreateTrueColor($new_w, $new_h);
    /* imageantialias($dst_img, true); */
    /* ImageCopyResized($dst_img, $src_img, 0,0,0,0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img)); */
    ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img));
    ImageJpeg($dst_img, "{$kimenet}");
}
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:25,代码来源:functions.php

示例2: newGalleryImage

 static function newGalleryImage($image)
 {
     # Grab filename and image type from upload
     $file_ext = self::$imageTypes[$image['type']];
     $filename = $image['name'];
     # Upload of image
     copy($image['tmp_name'], "gallery_images/" . $filename);
     # Grabs file suffix for variable function calls
     $function_suffix = strtoupper($file_ext);
     # Variable read/write functions for image creation
     $function_to_read = 'ImageCreateFrom' . $function_suffix;
     $function_to_write = 'Image' . $function_suffix;
     # Determine the file size and create a proportionally sized thumbnail
     $size = GetImageSize("gallery_images/" . $filename);
     if ($size[0] > $size[1]) {
         $thumbnail_width = 200;
         $thumbnail_height = (int) (200 * $size[1] / $size[0]);
     } else {
         $thumbnail_width = (int) (200 * $size[0] / $size[1]);
         $thumbnail_height = 200;
     }
     $source_handle = $function_to_read("gallery_images/" . $filename);
     if ($source_handle) {
         $destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height);
         ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]);
     }
     $function_to_write($destination_handle, "gallery_images/tb/" . $filename);
 }
开发者ID:michaeljmatthews22,项目名称:dightHum,代码行数:28,代码来源:class.Gallery.php

示例3: update_picture

 public function update_picture()
 {
     if (trim($_FILES["myfile"]["tmp_name"]) != "") {
         $images = $_FILES["myfile"]["tmp_name"];
         $new_images = "thumb_" . $this->session->userdata('std_cardid') . '_' . $_FILES["myfile"]["name"];
         copy($_FILES["myfile"]["tmp_name"], "assets/uploads/photo/" . $_FILES["myfile"]["name"]);
         $width = 150;
         //*** Fix Width & Heigh (Autu caculate) ***//
         $size = GetimageSize($images);
         $height = round($width * $size[1] / $size[0]);
         $images_orig = ImageCreateFromJPEG($images);
         $photoX = ImagesX($images_orig);
         $photoY = ImagesY($images_orig);
         $images_fin = ImageCreateTrueColor($width, $height);
         ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
         ImageJPEG($images_fin, "assets/uploads/photo/" . $new_images);
         ImageDestroy($images_orig);
         ImageDestroy($images_fin);
     }
     $fileName = $_FILES["myfile"]["name"];
     $ret[] = $fileName;
     $data_picture = array('std_picture' => $new_images);
     $this->Students_model->update_student_picture($this->session->userdata('std_cardid'), $data_picture);
     //echo  base_url()."assets/uploads/photo/".$new_images;
     redirect('/front_profiles/student_edit', 'refresh');
     //ChromePhp::log($ret);
     //exit;
 }
开发者ID:project2you,项目名称:student-attendance,代码行数:28,代码来源:front_profiles.php

示例4: resize

 public function resize($width, $height)
 {
     $type = exif_imagetype($this->image);
     if ($type == 2) {
         $images_orig = ImageCreateFromJPEG($this->image);
     } elseif ($type == 3) {
         $images_orig = ImageCreateFromPNG($this->image);
     } elseif ($type == 1) {
         $images_orig = ImageCreateFromGIF($this->image);
     } else {
         return false;
     }
     $photoX = ImagesX($images_orig);
     $photoY = ImagesY($images_orig);
     $images_fin = ImageCreateTrueColor($width, $height);
     ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
     if ($type == 2) {
         ImageJPEG($images_fin, $this->image);
     } elseif ($type == 3) {
         ImagePNG($images_fin, $this->image);
     } elseif ($type == 1) {
         ImageGIF($images_fin, $this->image);
     }
     ImageDestroy($images_orig);
     ImageDestroy($images_fin);
     return true;
 }
开发者ID:HyuchiaDiego,项目名称:Kirino,代码行数:27,代码来源:Image.php

示例5: image_resize_greyscale

function image_resize_greyscale(&$src_im)
{
    $src_x = ceil(imagesx($src_im));
    $src_y = ceil(imagesy($src_im));
    $dst_x = $src_x;
    $dst_y = $src_y;
    // http://php.about.com/od/gdlibrary/ss/grayscale_gd.htm
    function yiq($r, $g, $b)
    {
        return $r * 0.299 + $g * 0.587 + $b * 0.114;
    }
    $dst_im = ImageCreateTrueColor($dst_x, $dst_y);
    ImageCopyResampled($dst_im, $src_im, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
    for ($c = 0; $c < 256; $c++) {
        $palette[$c] = imagecolorallocate($dst_im, $c, $c, $c);
    }
    for ($y = 0; $y < $src_y; $y++) {
        for ($x = 0; $x < $src_x; $x++) {
            $rgb = imagecolorat($dst_im, $x, $y);
            $r = $rgb >> 16 & 0xff;
            $g = $rgb >> 8 & 0xff;
            $b = $rgb & 0xff;
            $gs = yiq($r, $g, $b);
            imagesetpixel($dst_im, $x, $y, $palette[$gs]);
        }
    }
    $src_im = $dst_im;
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:28,代码来源:filter.greyscale.inc.php

示例6: resizeImage

 private function resizeImage($file, $data, $tmd = 600, $quality = 100)
 {
     $data['type'] = "image/jpeg";
     $basename = basename($file);
     $filesDir = $this->input->post('uploadDir');
     // хэш нередактируемой карты!
     $uploaddir = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', $tmd, $filesDir), DIRECTORY_SEPARATOR);
     $srcFile = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', 'source', $filesDir, $basename), DIRECTORY_SEPARATOR);
     $image = $this->createimageByType($data, $srcFile);
     if (!file_exists($uploaddir)) {
         mkdir($uploaddir, 0775, true);
     }
     $size = GetImageSize($srcFile);
     $new = ImageCreateTrueColor($size['1'], $size['0']);
     if ($size['1'] > $tmd || $size['0'] > $tmd) {
         if ($size['1'] < $size['0']) {
             $hNew = round($tmd * $size['1'] / $size['0']);
             $new = ImageCreateTrueColor($tmd, $hNew);
             ImageCopyResampled($new, $image, 0, 0, 0, 0, $tmd, $hNew, $size['0'], $size['1']);
         }
         if ($size['1'] >= $size['0']) {
             $hNew = round($tmd * $size['0'] / $size['1']);
             $new = ImageCreateTrueColor($hNew, $tmd);
             ImageCopyResampled($new, $image, 0, 0, 0, 0, $hNew, $tmd, $size['0'], $size['1']);
         }
     }
     //print $uploaddir."/".TMD."/".$filename.".jpg<br>";
     imageJpeg($new, $uploaddir . DIRECTORY_SEPARATOR . $basename, $quality);
     //header("content-type: image/jpeg");// активировать для отладки
     //imageJpeg ($new, "", 100);//активировать для отладки
     imageDestroy($new);
 }
开发者ID:korzhevdp,项目名称:freehand,代码行数:32,代码来源:upload.php

示例7: execute

 function execute()
 {
     $gdimage =& $this->image->getImage();
     $w = $this->image->getWidth();
     $h = $this->image->getHeight();
     $src_x = ceil($w);
     $src_y = ceil($h);
     $dst_x = $src_x;
     $dst_y = $src_y;
     // http://php.about.com/od/gdlibrary/ss/grayscale_gd.htm
     function yiq($r, $g, $b)
     {
         return $r * 0.299 + $g * 0.587 + $b * 0.114;
     }
     $dst_im = ImageCreateTrueColor($dst_x, $dst_y);
     ImageCopyResampled($dst_im, $gdimage, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
     for ($c = 0; $c < 256; $c++) {
         $palette[$c] = imagecolorallocate($dst_im, $c, $c, $c);
     }
     for ($y = 0; $y < $src_y; $y++) {
         for ($x = 0; $x < $src_x; $x++) {
             $rgb = imagecolorat($dst_im, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $gs = yiq($r, $g, $b);
             imagesetpixel($dst_im, $x, $y, $palette[$gs]);
         }
     }
     $gdimage = $dst_im;
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:31,代码来源:class.rex_effect_filter_greyscale.inc.php

示例8: execute

 function execute()
 {
     if (!$this->image->isImage()) {
         return false;
     }
     $gdimage =& $this->image->getImage();
     $w = $this->image->getWidth();
     $h = $this->image->getHeight();
     $src_x = ceil($w);
     $src_y = ceil($h);
     $dst_x = $src_x;
     $dst_y = $src_y;
     $dst_im = ImageCreateTrueColor($dst_x, $dst_y);
     ImageCopyResampled($dst_im, $gdimage, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
     for ($c = 0; $c < 256; $c++) {
         $palette[$c] = imagecolorallocate($dst_im, $c, $c, $c);
     }
     for ($y = 0; $y < $src_y; $y++) {
         for ($x = 0; $x < $src_x; $x++) {
             $rgb = imagecolorat($dst_im, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $gs = $r * 0.299 + $g * 0.587 + $b * 0.114;
             imagesetpixel($dst_im, $x, $y, $palette[$gs]);
         }
     }
     $gdimage = $dst_im;
 }
开发者ID:Barnhiac,项目名称:MTW_REDAXO,代码行数:29,代码来源:class.rex_effect_filter_greyscale.inc.php

示例9: resize

 function resize($newX = false, $newY = false)
 {
     if ($this->img) {
         $X = ImageSX($this->img);
         $Y = ImageSY($this->img);
         $newX = $this->_convert($newX, $X);
         $newY = $this->_convert($newY, $Y);
         if (!$newX && !$newY) {
             $newX = $X;
             $newY = $Y;
         }
         if (!$newX) {
             $newX = round($X / ($Y / $newY));
         }
         if (!$newY) {
             $newY = round($Y / ($X / $newX));
         }
         if (!($newimg = ImageCreateTruecolor($newX, $newY))) {
             $newimg = ImageCreate($newX, $newY);
         }
         if (!ImageCopyResampled($newimg, $this->img, 0, 0, 0, 0, $newX, $newY, $X, $Y)) {
             ImageCopyResized($newimg, $this->img, 0, 0, 0, 0, $newX, $newY, $X, $Y);
         }
         $this->img = $newimg;
         return true;
     } else {
         return false;
     }
 }
开发者ID:BerlusGmbH,项目名称:Berlussimo,代码行数:29,代码来源:class_thumbs.php

示例10: thumb

function thumb($filename, $x, $y = 0)
{
    $t = getimagesize($filename) or die('Illegal type');
    $with = $t[0];
    $height = $t[1];
    switch ($t[2]) {
        case 1:
            $type = 'GIF';
            $img = imagecreatefromgif($filename);
            break;
        case 2:
            $type = 'JPEG';
            $img = imagecreatefromjpeg($filename);
            break;
        case 3:
            $type = 'PNG';
            $img = imagecreatefrompng($filename);
            break;
    }
    if ($y == 0) {
        $y = $x * ($height / $with);
    }
    header("Content-type: image/jpeg");
    $thumb = imagecreatetruecolor($x, $y);
    ImageCopyResampled($thumb, $img, 0, 0, 0, 0, $x, $y, $with, $height);
    $thumb = imagejpeg($thumb);
    return $thumb;
}
开发者ID:wilian32,项目名称:xbtit,代码行数:28,代码来源:thumbnail.php

示例11: crop

 public function crop($x, $y, $w, $h)
 {
     $this->sourceImageResoc = imagecreatefromjpeg($this->path . $this->name . '.' . $this->extension);
     $this->destinationImageResoc = ImageCreateTrueColor($w, $h);
     ImageCopyResampled($this->destinationImageResoc, $this->sourceImageResoc, 0, 0, $x, $y, $w, $h, $w, $h);
     return $this;
 }
开发者ID:badtux,项目名称:pmg,代码行数:7,代码来源:image.class.php

示例12: saveImg

 public function saveImg($path)
 {
     // Resize
     if ($this->resize) {
         $this->output = ImageCreateTrueColor($this->xOutput, $this->yOutput);
         ImageCopyResampled($this->output, $this->input, 0, 0, 0, 0, $this->xOutput, $this->yOutput, $this->xInput, $this->yInput);
     }
     // Save JPEG
     if ($this->format == "JPG" or $this->format == "JPEG") {
         if ($this->resize) {
             imageJPEG($this->output, $path, $this->quality);
         } else {
             copy($this->src, $path);
         }
     } elseif ($this->format == "PNG") {
         if ($this->resize) {
             imagePNG($this->output, $path);
         } else {
             copy($this->src, $path);
         }
     } elseif ($this->format == "GIF") {
         if ($this->resize) {
             imageGIF($this->output, $path);
         } else {
             copy($this->src, $path);
         }
     }
 }
开发者ID:Mojolagbe2014,项目名称:mojoimipakiti,代码行数:28,代码来源:Imaging.php

示例13: execute

 public function execute()
 {
     $this->media->asImage();
     $gdimage = $this->media->getImage();
     $w = $this->media->getWidth();
     $h = $this->media->getHeight();
     $src_x = ceil($w);
     $src_y = ceil($h);
     $dst_x = $src_x;
     $dst_y = $src_y;
     $dst_im = ImageCreateTrueColor($dst_x, $dst_y);
     ImageCopyResampled($dst_im, $gdimage, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
     for ($c = 0; $c < 256; ++$c) {
         $palette[$c] = imagecolorallocate($dst_im, $c, $c, $c);
     }
     for ($y = 0; $y < $src_y; ++$y) {
         for ($x = 0; $x < $src_x; ++$x) {
             $rgb = imagecolorat($dst_im, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $gs = $r * 0.299 + $g * 0.587 + $b * 0.114;
             imagesetpixel($dst_im, $x, $y, $palette[$gs]);
         }
     }
     $this->media->setImage($dst_im);
 }
开发者ID:staabm,项目名称:redaxo,代码行数:27,代码来源:effect_filter_greyscale.php

示例14: cropBilde

 private function cropBilde($sti, $filnavn, $nyttFilnavn, $cropBredde, $cropHoyde)
 {
     $gammeltBilde = $sti . $filnavn;
     $bi = @ImageCreateFromJPEG($gammeltBilde) or $bi = @ImageCreateFromPNG($gammeltBilde) or $bi = @ImageCreateFromGIF($gammeltBilde) or $bi = false;
     if ($bi) {
         $naStorrelse = @getimagesize($gammeltBilde);
         $bredde = $naStorrelse[0];
         $hoyde = $naStorrelse[1];
         $nyBreddeNy = $bredde / $cropBredde;
         $nyHoydeNy = $hoyde / $cropHoyde;
         $halvertHoyde = $cropHoyde / 2;
         $halvertBredde = $cropBredde / 2;
         $thumb = @ImageCreateTrueColor($cropBredde, $cropHoyde);
         if ($bredde > $hoyde) {
             $tilpassetBredde = $bredde / $nyHoydeNy;
             $halvBredde = $tilpassetBredde / 2;
             $intBredde = $halvBredde - $halvertBredde;
             @ImageCopyResampled($thumb, $bi, -$intBredde, 0, 0, 0, $tilpassetBredde, $cropHoyde, $bredde, $hoyde);
         } elseif ($bredde < $hoyde || $bredde == $hoyde) {
             $tilPassetHoyde = $hoyde / $nyBreddeNy;
             $halvHoyde = $tilPassetHoyde / 2;
             $intHoyde = $halvHoyde - $halvertHoyde;
             @ImageCopyResampled($thumb, $bi, 0, -$intHoyde, 0, 0, $cropBredde, $tilPassetHoyde, $bredde, $hoyde);
         } else {
             @ImageCopyResampled($thumb, $bi, 0, 0, 0, 0, $cropBredde, $cropHoyde, $bredde, $hoyde);
         }
         @imagejpeg($thumb, $sti . $nyttFilnavn, 50);
         return $nyttFilnavn;
     } else {
         return -1;
     }
 }
开发者ID:Jeremiah0211,项目名称:airdog,代码行数:32,代码来源:BildeendringController.php

示例15: resize_image

 public function resize_image($data, $imgX, $sizedef, $lid, $imgid)
 {
     $file = $data["raw_name"];
     $type = $data["file_ext"];
     $outfile = $imgX[$sizedef]['dir'] . "/" . $lid . "/" . $file . '.jpg';
     $path = $this->config->item("upload_dir");
     $image = $this->create_image_container($file, $type);
     if ($image) {
         $size = GetImageSize($path . $file . $type);
         $old = $image;
         // сей форк - не просто так. непонятно, правда, почему...
         if ($size['1'] < $size['0']) {
             $h_new = round($imgX[$sizedef]['max_dim'] * ($size['1'] / $size['0']));
             $measures = array($imgX[$sizedef]['max_dim'], $h_new);
         }
         if ($size['1'] >= $size['0']) {
             $h_new = round($imgX[$sizedef]['max_dim'] * ($size['0'] / $size['1']));
             $measures = array($h_new, $imgX[$sizedef]['max_dim']);
         }
         $new = ImageCreateTrueColor($measures[0], $measures[1]);
         ImageCopyResampled($new, $image, 0, 0, 0, 0, $measures[0], $measures[1], $size['0'], $size['1']);
         imageJpeg($new, $outfile, $imgX[$sizedef]['quality']);
         $this->db->query("UPDATE `images` SET `images`.`" . $sizedef . "` = ? WHERE `images`.`id` = ?", array(implode($measures, ","), $imgid));
         imageDestroy($new);
     }
 }
开发者ID:korzhevdp,项目名称:MiniGIS,代码行数:26,代码来源:uploadmodel.php


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