• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagesy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createnewpicture

 private function createnewpicture()
 {
     $local = $this->path_two . $this->file['name'];
     move_uploaded_file($this->file['tmp_name'], $local);
     $filename = $this->file['tmp_name'] . "/" . $this->file['name'];
     $this->location = $this->path . "/" . $this->file['name'];
     switch ($this->file['type']) {
         case 'image/jpeg':
             $src = imagecreatefromjpeg($local);
             break;
         case 'image/png':
             $src = imagecreatefrompng($local);
             break;
         case 'image/gif':
             $src = imagecreatefromgif($local);
             break;
         default:
             break;
     }
     $sx = imagesx($src);
     $sy = imagesy($src);
     $new_image = imagecreatetruecolor($this->newwidth, $this->newheight);
     if (imagecopyresized($new_image, $src, 0, 0, 0, 0, $this->newwidth, $this->newheight, $sx, $sy)) {
         if (ImageJpeg($new_image, $this->location) || Imagegif($new_image, $this->location) || Imagepng($new_image, $this->location)) {
             //imagejpeg($this->location);
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:JiaJia01,项目名称:homework_09,代码行数:31,代码来源:picture.php


示例2: cacheImage

/**
 * Generate a cached thumbnail for object lists (eg. carrier, order states...etc)
 *
 * @param string $image Real image filename
 * @param string $cacheImage Cached filename
 * @param integer $size Desired size
 */
function cacheImage($image, $cacheImage, $size, $imageType = 'jpg')
{
    if (file_exists($image)) {
        if (!file_exists(_PS_TMP_IMG_DIR_ . $cacheImage)) {
            $imageGd = $imageType == 'gif' ? imagecreatefromgif($image) : imagecreatefromjpeg($image);
            $x = imagesx($imageGd);
            $y = imagesy($imageGd);
            /* Size is already ok */
            if ($y < $size) {
                copy($image, _PS_TMP_IMG_DIR_ . $cacheImage);
            } else {
                $ratioX = $x / ($y / $size);
                $newImage = $imageType == 'gif' ? imagecreate($ratioX, $size) : imagecreatetruecolor($ratioX, $size);
                /* Allow to keep nice look even if resized */
                $white = imagecolorallocate($newImage, 255, 255, 255);
                imagefill($newImage, 0, 0, $white);
                imagecopyresampled($newImage, $imageGd, 0, 0, 0, 0, $ratioX, $size, $x, $y);
                imagecolortransparent($newImage, $white);
                /* Quality alteration and image creation */
                if ($imageType == 'gif') {
                    imagegif($newImage, _PS_TMP_IMG_DIR_ . $cacheImage);
                } else {
                    imagejpeg($newImage, _PS_TMP_IMG_DIR_ . $cacheImage, 86);
                }
            }
        }
        return '<img src="../img/tmp/' . $cacheImage . '" alt="" class="imgm" />';
    }
    return '';
}
开发者ID:sealence,项目名称:local,代码行数:37,代码来源:images.inc.php


示例3: hacknrollify

function hacknrollify($picfilename)
{
    $logofilename = "logo.png";
    $logoPicPath = "logopics/" . $logofilename;
    $originalPicPath = "originalpics/" . $picfilename;
    $editedfilename = "hnr_" . $picfilename;
    $editedPicPath = "editedpics/" . $editedfilename;
    // read the original image from file
    $profilepic = imagecreatefromjpeg($originalPicPath);
    $profilepicWidth = imagesx($profilepic);
    $profilepicHeight = imagesy($profilepic);
    // create the black image overlay
    $blackoverlay = imagecreate($profilepicWidth, $profilepicHeight);
    imagecolorallocate($blackoverlay, 0, 0, 0);
    // then merge the black and profilepic
    imagecopymerge($profilepic, $blackoverlay, 0, 0, 0, 0, $profilepicWidth, $profilepicHeight, 50);
    imagedestroy($blackoverlay);
    // merge the resized logo
    $logo = resizeImage($logoPicPath, $profilepicWidth - 80, 999999);
    imageAlphaBlending($logo, false);
    imageSaveAlpha($logo, true);
    $logoWidth = imagesx($logo);
    $logoHeight = imagesy($logo);
    $verticalOffset = $profilepicHeight / 2 - $logoHeight / 2;
    $horizontalOffset = 40;
    imagecopyresampled($profilepic, $logo, $horizontalOffset, $verticalOffset, 0, 0, $logoWidth, $logoHeight, $logoWidth, $logoHeight);
    $mergeSuccess = imagejpeg($profilepic, $editedPicPath);
    if (!$mergeSuccess) {
        echo "Image merge failed!";
    }
    imagedestroy($profilepic);
    imagedestroy($logo);
    return $editedPicPath;
}
开发者ID:nicholaslum444,项目名称:HacknRollify,代码行数:34,代码来源:lib_hacknrollify.php


示例4: resizewidth

 static function resizewidth($width, $imageold, $imagenew)
 {
     $image_info = getimagesize($imageold);
     $image_type = $image_info[2];
     if ($image_type == IMAGETYPE_JPEG) {
         $image = imagecreatefromjpeg($imageold);
     } elseif ($this->image_type == IMAGETYPE_GIF) {
         $image = imagecreatefromgif($imageold);
     } elseif ($this->image_type == IMAGETYPE_PNG) {
         $image = imagecreatefrompng($imageold);
     }
     $ratio = imagesy($image) / imagesx($image);
     $height = $width * $ratio;
     //$width = imagesx($image) * $width/100;
     // $height = imagesx($image) * $width/100;
     $new_image = imagecreatetruecolor($width, $height);
     imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
     $image = $new_image;
     $compression = 75;
     $permissions = null;
     if ($image_type == IMAGETYPE_JPEG) {
         imagejpeg($image, $imagenew, $compression);
     } elseif ($image_type == IMAGETYPE_GIF) {
         imagegif($image, $imagenew);
     } elseif ($image_type == IMAGETYPE_PNG) {
         imagepng($image, $imagenew);
     }
     if ($permissions != null) {
         chmod($imagenew, $permissions);
     }
 }
开发者ID:blackorwhite1233,项目名称:fakekinhdoanh,代码行数:31,代码来源:SimpleImage.php


示例5: apply

 public function apply($resource)
 {
     // Extract arguments
     @(list(, $direction, $step, $thickness, $color) = func_get_args());
     $step = (int) $step;
     $thickness = (int) $thickness;
     if ($step < 2) {
         $step = 2;
     }
     // Get resolution
     $width = imagesx($resource);
     $height = imagesy($resource);
     if ($width === false || $height === false) {
         throw new Exception("An error was encountered while getting image resolution");
     }
     // Apply effect
     switch ($direction) {
         case self::VERTICAL:
             $x = 0;
             while (($x += $step) < $width) {
                 parent::apply($resource, $x, 0, $x, $height, $thickness, $color);
             }
             break;
         case self::HORIZONTAL:
         default:
             $y = 0;
             while (($y += $step) < $height) {
                 parent::apply($resource, 0, $y, $width, $y, $thickness, $color);
             }
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:32,代码来源:Lines.php


示例6: ImageManipulation

 /**
  * Contructor method. Will create a new image from the target file.
  * Accepts an image filename as a string. Method also works out how
  * big the image is and stores this in the $image array.
  *
  * @param string $imgFile The image filename.
  */
 public function ImageManipulation($imgfile)
 {
     //detect image format
     $this->image["format"] = preg_replace("/.*\\.(.*)\$/", "\\1", $imgfile);
     //$this->image["format"] = preg_replace(".*\.(.*)$", "\\1", $imgfile);
     $this->image["format"] = strtoupper($this->image["format"]);
     // convert image into usable format.
     if ($this->image["format"] == "JPG" || $this->image["format"] == "JPEG") {
         //JPEG
         $this->image["format"] = "JPEG";
         $this->image["src"] = ImageCreateFromJPEG($imgfile);
     } elseif ($this->image["format"] == "PNG") {
         //PNG
         $this->image["format"] = "PNG";
         $this->image["src"] = imagecreatefrompng($imgfile);
     } elseif ($this->image["format"] == "GIF") {
         //GIF
         $this->image["format"] = "GIF";
         $this->image["src"] = ImageCreateFromGif($imgfile);
     } elseif ($this->image["format"] == "WBMP") {
         //WBMP
         $this->image["format"] = "WBMP";
         $this->image["src"] = ImageCreateFromWBMP($imgfile);
     } else {
         //DEFAULT
         return false;
     }
     // Image is ok
     $this->imageok = true;
     // Work out image size
     $this->image["sizex"] = imagesx($this->image["src"]);
     $this->image["sizey"] = imagesy($this->image["src"]);
 }
开发者ID:ali-codehoppers,项目名称:adventskalender,代码行数:40,代码来源:ImageManipulation.php


示例7: getHashValue

 public function getHashValue($img)
 {
     $width = imagesx($img);
     $height = imagesy($img);
     $total = 0;
     $array = array();
     for ($y = 0; $y < $height; $y++) {
         for ($x = 0; $x < $width; $x++) {
             $gray = imagecolorat($img, $x, $y) >> 8 & 0xff;
             if (!is_array($array[$y])) {
                 $array[$y] = array();
             }
             $array[$y][$x] = $gray;
             $total += $gray;
         }
     }
     $average = intval($total / (64 * $this->rate * $this->rate));
     $result = '';
     for ($y = 0; $y < $height; $y++) {
         for ($x = 0; $x < $width; $x++) {
             if ($array[$y][$x] >= $average) {
                 $result .= '1';
             } else {
                 $result .= '0';
             }
         }
     }
     return $result;
 }
开发者ID:676496871,项目名称:Demo,代码行数:29,代码来源:Imghash.class.php


示例8: resizeTo

 public function resizeTo($width, $height)
 {
     if (osc_use_imagick()) {
         $bg = new Imagick();
         $bg->newImage($width, $height, 'white');
         $this->im->thumbnailImage($width, $height, true);
         $geometry = $this->im->getImageGeometry();
         $x = ($width - $geometry['width']) / 2;
         $y = ($height - $geometry['height']) / 2;
         $bg->compositeImage($this->im, imagick::COMPOSITE_OVER, $x, $y);
         $this->im = $bg;
     } else {
         $w = imagesx($this->im);
         $h = imagesy($this->im);
         if ($w / $h >= $width / $height) {
             //$newW = $width;
             $newW = $w > $width ? $width : $w;
             $newH = $h * ($newW / $w);
         } else {
             //$newH = $height;
             $newH = $h > $height ? $height : $h;
             $newW = $w * ($newH / $h);
         }
         $newIm = imagecreatetruecolor($width, $height);
         //$newW, $newH);
         imagealphablending($newIm, false);
         $colorTransparent = imagecolorallocatealpha($newIm, 255, 255, 255, 127);
         imagefill($newIm, 0, 0, $colorTransparent);
         imagesavealpha($newIm, true);
         imagecopyresampled($newIm, $this->im, ($width - $newW) / 2, ($height - $newH) / 2, 0, 0, $newW, $newH, $w, $h);
         imagedestroy($this->im);
         $this->im = $newIm;
     }
     return $this;
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:35,代码来源:ImageResizer.php


示例9: putImage

 /**
  * method puts image onto map image
  * 
  * @param Map  $map
  * @param resources $imageToPut
  */
 public function putImage(Map $map, $imageToPut)
 {
     $mapImage = $map->getImage();
     $width = imagesx($imageToPut);
     $height = imagesy($imageToPut);
     imagecopy($mapImage, $imageToPut, imagesx($mapImage) - $width, 0, 0, 0, $width, $height);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:13,代码来源:RightUpCorner.php


示例10: filter

 public function filter($value)
 {
     if (!file_exists($value)) {
         throw new Zend_Filter_Exception('Image does not exist: ' . $value);
     }
     $image = imagecreatefromstring(file_get_contents($value));
     if (false === $image) {
         throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
     }
     // find ratio to scale down to
     // TODO: pass 600 as parameter in the future
     $origWidth = imagesx($image);
     $origHeight = imagesy($image);
     $ratio = max($origWidth, $origHeight) / 600;
     if ($ratio > 1) {
         // img too big! create a scaled down image
         $newWidth = round($origWidth / $ratio);
         $newHeight = round($origHeight / $ratio);
         $resized = imagecreatetruecolor($newWidth, $newHeight);
         imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
         // determine type and store to disk
         $explodeResult = explode(".", $value);
         $type = strtolower($explodeResult[count($explodeResult) - 1]);
         $writeFunc = 'image' . $type;
         if ($type == 'jpeg' || $type == 'jpg') {
             imagejpeg($resized, $value, 100);
         } else {
             $writeFunc($resized, $value);
         }
     }
     return $value;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:32,代码来源:ImageSize.php


示例11: create_pic

function create_pic($upfile, $new_path, $width)
{
    $quality = 100;
    $image_path = $upfile;
    $image_info = getimagesize($image_path);
    $exname = '';
    //1  =  GIF,  2  =  JPG,  3  =  PNG,  4  =  SWF,  5  =  PSD,  6  =  BMP,  7  =  TIFF(intel  byte  order),  8  =  TIFF(motorola  byte  order),  9  =  JPC,  10  =  JP2,  11  =  JPX,  12  =  JB2,  13  =  SWC,  14  =  IFF
    switch ($image_info[2]) {
        case 1:
            @($image = imagecreatefromgif($image_path));
            $exname = 'gif';
            break;
        case 2:
            @($image = imagecreatefromjpeg($image_path));
            $exname = 'jpg';
            break;
        case 3:
            @($image = imagecreatefrompng($image_path));
            $exname = 'png';
            break;
        case 6:
            @($image = imagecreatefromwbmp($image_path));
            $exname = 'wbmp';
            break;
    }
    $T_width = $image_info[0];
    $T_height = $image_info[1];
    if (!empty($image)) {
        $image_x = imagesx($image);
        $image_y = imagesy($image);
    } else {
        return FALSE;
    }
    @chmod($new_path, 0777);
    if ($image_x > $width) {
        $x = $width;
        $y = intval($x * $image_y / $image_x);
    } else {
        @copy($image_path, $new_path . '.' . $exname);
        return $exname;
    }
    $newimage = imagecreatetruecolor($x, $y);
    imagecopyresampled($newimage, $image, 0, 0, 0, 0, $x, $y, $image_x, $image_y);
    switch ($image_info[2]) {
        case 1:
            imagegif($newimage, $new_path . '.gif', $quality);
            break;
        case 2:
            imagejpeg($newimage, $new_path . '.jpg', $quality);
            break;
        case 3:
            imagepng($newimage, $new_path . '.png', $quality);
            break;
        case 6:
            imagewbmp($newimage, $new_path . '.wbmp', $quality);
            break;
    }
    imagedestroy($newimage);
    return $exname;
}
开发者ID:yunsite,项目名称:cyaskuc,代码行数:60,代码来源:global.func.php


示例12: setImage

 /**
  * Set the image variable by using image create
  *
  * @param string $filename - The image filename
  */
 private function setImage($filename)
 {
     $size = getimagesize($filename);
     $this->ext = $size['mime'];
     switch ($this->ext) {
         // Image is a JPG
         case 'image/jpg':
         case 'image/jpeg':
             // create a jpeg extension
             $this->image = imagecreatefromjpeg($filename);
             break;
             // Image is a GIF
         // Image is a GIF
         case 'image/gif':
             $this->image = @imagecreatefromgif($filename);
             break;
             // Image is a PNG
         // Image is a PNG
         case 'image/png':
             $this->image = @imagecreatefrompng($filename);
             break;
             // Mime type not found
         // Mime type not found
         default:
             throw new Exception("File is not an image, please use another file type.", 1);
     }
     $this->origWidth = imagesx($this->image);
     $this->origHeight = imagesy($this->image);
 }
开发者ID:swarajjena,项目名称:hackathon,代码行数:34,代码来源:Resize_image.php


示例13: resize_image

function resize_image($pathToImages, $pathToThumbs, $thumbWidth)
{
    // open the directory
    $dir = opendir($pathToImages);
    // loop through it, looking for any/all JPG files:
    while (false !== ($fname = readdir($dir))) {
        // parse path for the extension
        $info = pathinfo($pathToImages . $fname);
        // continue only if this is a JPEG image
        if (strtolower($info['extension']) == 'jpg' && $fname != "thumb.jpg") {
            // load image and get image size
            $img = imagecreatefromjpeg("{$pathToImages}" . "/" . "{$fname}");
            $width = imagesx($img);
            $height = imagesy($img);
            // calculate thumbnail size
            $new_width = $thumbWidth;
            $new_height = floor($height * ($thumbWidth / $width));
            // create a new temporary image
            $tmp_img = imagecreatetruecolor($new_width, $new_height);
            // copy and resize old image into new image
            imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            // save thumbnail into a file
            imagejpeg($tmp_img, "{$pathToThumbs}" . "/" . "{$fname}");
            echo "Se redujo la imagen  {$fname} <br />";
            //echo "$pathToThumbs" . "/" . "$fname<br/>";
        }
    }
    // close the directory
    closedir($dir);
}
开发者ID:tineo,项目名称:webapoyopublicitario,代码行数:30,代码来源:index.php


示例14: apply

 /**
  * {@inheritdoc}
  */
 public function apply(&$image)
 {
     $inputWidth = imagesx($image);
     $inputHeight = imagesy($image);
     $width = $inputWidth;
     $height = $inputHeight;
     // bigger
     if ($height < $this->outputHeight) {
         $width = $this->outputHeight / $height * $width;
         $height = $this->outputHeight;
     }
     if ($width < $this->outputWidth) {
         $height = $this->outputWidth / $width * $height;
         $width = $this->outputWidth;
     }
     // taller
     if ($height > $this->outputHeight) {
         $width = $this->outputHeight / $height * $width;
         $height = $this->outputHeight;
     }
     // wider
     if ($width > $this->outputWidth) {
         $height = $this->outputWidth / $width * $height;
         $width = $this->outputWidth;
     }
     $output = imagecreatetruecolor($width, $height);
     imagecopyresampled($output, $image, 0, 0, 0, 0, $width, $height, $inputWidth, $inputHeight);
     $image = $output;
 }
开发者ID:moust,项目名称:paint,代码行数:32,代码来源:Resize.php


示例15: upload

function upload($tmp, $name, $nome, $larguraP, $pasta)
{
    $ext = strtolower(end(explode('.', $name)));
    if ($ext == 'jpg') {
        $img = imagecreatefromjpeg($tmp);
    } elseif ($ext == 'gif') {
        $img = imagecreatefromgif($tmp);
    } else {
        $img = imagecreatefrompng($tmp);
    }
    $x = imagesx($img);
    $y = imagesy($img);
    $largura = $x > $larguraP ? $larguraP : $x;
    $altura = $largura * $y / $x;
    if ($altura > $larguraP) {
        $altura = $larguraP;
        $largura = $altura * $x / $y;
    }
    $nova = imagecreatetruecolor($largura, $altura);
    imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
    imagejpeg($nova, "{$pasta}/{$nome}");
    imagedestroy($img);
    imagedestroy($nova);
    return $nome;
}
开发者ID:mauriliovilela,项目名称:ser-social,代码行数:25,代码来源:funcoes.php


示例16: ImageHue

 public static function ImageHue(&$image, $hue, $saturation)
 {
     $width = imagesx($image);
     $height = imagesy($image);
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $rgb = imagecolorat($image, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $alpha = ($rgb & 0x7f000000) >> 24;
             $hsl = ColorUtils::rgb2hsl(array('r' => $r, 'g' => $g, 'b' => $b));
             $h = $hsl['h'] / 360;
             $s = $hsl['s'] / 100;
             $h += $hue / 360;
             $s += $saturation / 100;
             if ($h > 1) {
                 $h--;
             }
             if ($s > 1) {
                 $s--;
             }
             $hsl['h'] = $h * 360;
             $hsl['s'] = $s * 100;
             $rgb = ColorUtils::hsl2rgb($hsl);
             imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $rgb['r'], $rgb['g'], $rgb['b'], $alpha));
         }
     }
 }
开发者ID:rsids,项目名称:bright_api,代码行数:29,代码来源:ImageUtils.php


示例17: thumbnail

 /**
  * 压缩图像尺寸
  * @param $pic 源图像
  * @param $dst_pic 目标图像
  * @param $width 宽度
  * @param $height 高度
  * @param $qulitity 质量
  * @return unknown_type
  */
 static function thumbnail($pic, $dst_pic, $max_width, $max_height = null, $qulitity = 100, $copy = true)
 {
     $im = self::readfile($pic);
     $old_w = imagesx($im);
     $old_h = imagesy($im);
     if ($max_height == null) {
         $max_height = $max_width;
     }
     if ($old_w > $max_width or $old_h > $max_height) {
         $w_h = $old_w / $old_h;
         $h_w = $old_h / $old_w;
         if ($w_h > $h_w) {
             $width = $max_width;
             $height = $width * $h_w;
         } else {
             $height = $max_height;
             $width = $height * $w_h;
         }
         $newim = imagecreatetruecolor($width, $height);
         imagecopyresampled($newim, $im, 0, 0, 0, 0, $width, $height, $old_w, $old_h);
         imagejpeg($newim, $dst_pic, $qulitity);
         imagedestroy($im);
     } elseif ($pic != $dst_pic and $copy) {
         copy($pic, $dst_pic);
     }
 }
开发者ID:jinguanio,项目名称:swoolecrawler,代码行数:35,代码来源:Image.php


示例18: open

 public function open($file)
 {
     $this->close();
     // *** Get extension
     $extension = strtolower(strrchr($file, '.'));
     switch ($extension) {
         case '.jpg':
         case '.jpeg':
             $this->image = @imagecreatefromjpeg($file);
             break;
         case '.gif':
             $this->image = @imagecreatefromgif($file);
             break;
         case '.png':
             $this->image = @imagecreatefrompng($file);
             break;
         default:
             $this->image = FALSE;
             break;
     }
     if ($this->image !== FALSE) {
         // *** Get width and height
         $this->width = imagesx($this->image);
         $this->height = imagesy($this->image);
     }
     return $this->image;
 }
开发者ID:atomicon,项目名称:atomicon-gallery,代码行数:27,代码来源:atomicon-gallery-image.php


示例19: set

 function set($a_image)
 {
     $this->clear();
     $this->m_handle = $a_image;
     $this->m_width = imagesx($this->m_handle);
     $this->m_height = imagesy($this->m_handle);
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:7,代码来源:image.php


示例20: player

 /**
  *
  * @param string $playername Minecraft player name
  * @param resource $avatar the rendered avatar (for example player head)
  *
  * @param string $background Image Path or Standard Value
  * @return resource the generated banner
  */
 public static function player($playername, $avatar = NULL, $background = NULL)
 {
     $canvas = MinecraftBanner::getBackgroundCanvas(self::PLAYER_WIDTH, self::PLAYER_HEIGHT, $background);
     $head_height = self::AVATAR_SIZE;
     $head_width = self::AVATAR_SIZE;
     $avater_x = self::PLAYER_PADDING;
     $avater_y = self::PLAYER_HEIGHT / 2 - self::AVATAR_SIZE / 2;
     if ($avatar == NULL) {
         $avatar = imagecreatefrompng(__DIR__ . "/img/head.png");
         imagesavealpha($avatar, true);
         imagecopy($canvas, $avatar, $avater_x, $avater_y, 0, 0, $head_width, $head_height);
     } else {
         $head_width = imagesx($avatar);
         $head_height = imagesy($avatar);
         if ($head_width > self::AVATAR_SIZE) {
             $head_width = self::AVATAR_SIZE;
         }
         if ($head_height > self::AVATAR_SIZE) {
             $head_height = self::AVATAR_SIZE;
         }
         $center_x = $avater_x + self::AVATAR_SIZE / 2 - $head_width / 2;
         $center_y = $avater_y + self::AVATAR_SIZE / 2 - $head_height / 2;
         imagecopy($canvas, $avatar, $center_x, $center_y, 0, 0, $head_width, $head_height);
     }
     $box = imagettfbbox(self::TEXT_SIZE, 0, MinecraftBanner::FONT_FILE, $playername);
     $text_width = abs($box[4] - $box[0]);
     $text_color = imagecolorallocate($canvas, 255, 255, 255);
     $remaining = self::PLAYER_WIDTH - self::AVATAR_SIZE - $avater_x - self::PLAYER_PADDING;
     $text_posX = $avater_x + self::AVATAR_SIZE + $remaining / 2 - $text_width / 2;
     $text_posY = $avater_y + self::AVATAR_SIZE / 2 + self::TEXT_SIZE / 2;
     imagettftext($canvas, self::TEXT_SIZE, 0, $text_posX, $text_posY, $text_color, MinecraftBanner::FONT_FILE, $playername);
     return $canvas;
 }
开发者ID:games647,项目名称:minecraft-banner-generator,代码行数:41,代码来源:PlayerBanner.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagetruecolortopalette函数代码示例发布时间:2022-05-15
下一篇:
PHP imagesx函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap