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


PHP imagecreatefromgd函数代码示例

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


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

示例1: setImage

 function setImage($image, $imageType = '')
 {
     $this->setImageInfo($image);
     if ($this->imageType == 'unknown') {
         $this->imageType = $imageType;
         if (empty($this->imageType) || $this->imageType == 'unknown') {
             die("Specify imageType to scale from");
         }
     }
     if ($this->imageType == 'gif') {
         $this->image = imagecreatefromgif($image);
     } else {
         if ($this->imageType == 'jpg' || $this->imageType == 'jpeg') {
             $this->image = imagecreatefromjpeg($image);
         } else {
             if ($this->imageType == 'png') {
                 $this->image = imagecreatefrompng($image);
             } else {
                 if ($this->imageType == 'gd') {
                     $this->image = imagecreatefromgd($image);
                 } else {
                     die("Unsupported source image type: {$imageType}");
                 }
             }
         }
     }
 }
开发者ID:innomatic-libs,项目名称:scaleimagelib,代码行数:27,代码来源:ScaleImage.php

示例2: readImage0

 /**
  * Read image via imagecreatefromgd()
  *
  * @param   string uri
  * @return  resource
  * @throws  img.ImagingException
  */
 protected function readImage0($uri)
 {
     if (FALSE === ($r = imagecreatefromgd($uri))) {
         $e = new ImagingException('Cannot read image');
         xp::gc(__FILE__);
         throw $e;
     }
     return $r;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:16,代码来源:GDStreamReader.class.php

示例3: readImageFromUri

 /**
  * Read image
  *
  * @param   string uri
  * @return  resource
  * @throws  img.ImagingException
  */
 public function readImageFromUri($uri)
 {
     if (FALSE === ($r = imagecreatefromgd($uri))) {
         $e = new ImagingException('Cannot read image from "' . $uri . '"');
         xp::gc(__FILE__);
         throw $e;
     }
     return $r;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:16,代码来源:GDStreamReader.class.php

示例4: openUnknown

 protected static function openUnknown($img)
 {
     if ($tmpImg2 = imagecreatefromstring($img)) {
         $wight = imagesx($tmpImg2);
         $height = imagesy($tmpImg2);
         $tmpImg = imagecreatetruecolor($wight, $height);
         $white = imagecolorallocate($tmpImg, 255, 255, 255);
         imagefill($tmpImg, 0, 0, $white);
         imagecopy($tmpImg, $tmpImg2, 0, 0, 0, 0, $wight, $height);
         imagedestroy($tmpImg2);
     } else {
         $tmpImg = imagecreatefromgd($img);
     }
     return $tmpImg;
 }
开发者ID:bpteam,项目名称:php-ocr,代码行数:15,代码来源:Img.php

示例5: loadImage

 public function loadImage($file)
 {
     /*
     	Open the image and create the resource
     */
     // Check if the GD extension is loaded
     if (!extension_loaded('gd')) {
         if (!dl('gd.' . PHP_SHLIB_SUFFIX)) {
             $this->lastError = 'GD is not loaded';
             return false;
         }
     }
     if (is_string($file) === true && is_file($file) === true && file_exists($file) === true && is_readable($file) === true) {
         $file = realpath($file);
         $imgSize = getimagesize($file);
         if ($imgSize !== false) {
             // Get the image from file
             if ($imgSize['mime'] === 'image/jpeg') {
                 $resource = imagecreatefromjpeg($file);
             } else {
                 if ($imgSize['mime'] === 'image/gif') {
                     $resource = imagecreatefromgif($file);
                 } else {
                     if ($imgSize['mime'] === 'image/png') {
                         $resource = imagecreatefrompng($file);
                     } else {
                         if ($imgSize['mime'] === 'image/bmp') {
                             $resource = imagecreatefromgd($file);
                         } else {
                             $this->lastError = 'Not supported format to load';
                             return false;
                         }
                     }
                 }
             }
             $this->imgResource = $resource;
             $this->imgFile = $file;
             $this->imgSize = $imgSize;
             $this->ready = true;
             return true;
         }
         $this->lastError = 'File is not image';
         return false;
     }
     $this->lastError = 'File load problem (not exist/not file/not readable)';
     return false;
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:47,代码来源:imgtools_class.php

示例6: _from

 /**
  * 根据原始文件的扩展名,返回从原始文件创建的一个画布
  * @return resource 返回从原始文件取得的一个图像
  */
 private function _from()
 {
     switch ($this->src_img_ext) {
         case "gd2":
             return imagecreatefromgd2($this->src_img);
         case "gd":
             return imagecreatefromgd($this->src_img);
         case "gif":
             return imagecreatefromgif($this->src_img);
         case "jpeg":
             return imagecreatefromjpeg($this->src_img);
         case "jpg":
             return imagecreatefromjpeg($this->src_img);
         case "png":
             return imagecreatefrompng($this->src_img);
         default:
             return FALSE;
     }
 }
开发者ID:gtyd,项目名称:jira,代码行数:23,代码来源:File.php

示例7: open_image

function open_image($file)
{
    $im = @imagecreatefromjpeg($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgif($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefrompng($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgd($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgd2($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromwbmp($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromxbm($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromxpm($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromstring(file_get_contents($file));
    if ($im !== false) {
        return $im;
    }
    return false;
}
开发者ID:madr,项目名称:urban-octo-rotary-phone,代码行数:40,代码来源:common.php

示例8: loadGD

 public function loadGD($sFile)
 {
     $this->rImage = imagecreatefromgd($sFile);
 }
开发者ID:vulcandth,项目名称:steamprofile,代码行数:4,代码来源:GDImage.php

示例9: imagecreatefrombmp

function imagecreatefrombmp($filename)
{
    $tmp_name = tempnam("/tmp", "GD");
    if (ConvertBMP2GD($filename, $tmp_name)) {
        $img = imagecreatefromgd($tmp_name);
        unlink($tmp_name);
        return $img;
    }
    return false;
}
开发者ID:bmad4ever,项目名称:LTW,代码行数:10,代码来源:bmp_converter.php

示例10: count

     $n = count($exts) - 1;
     $suffix = $exts[$n];
 }
 //print "suffix: '$suffix'<br />";
 mysqltest();
 if ($suffix == "jpeg" || $suffix == "jpg" || $suffix == "jif" || $suffix == "jpe") {
     $im = @imagecreatefromjpeg($localtempfile);
 } else {
     if ($suffix == "png") {
         $im = @imagecreatefrompng($localtempfile);
     } else {
         if ($suffix == "gif") {
             $im = @imagecreatefromgif($localtempfile);
         } else {
             if ($suffix == "gd") {
                 $im = @imagecreatefromgd($localtempfile);
             } else {
                 if ($suffix == "gd2") {
                     $im = @imagecreatefromgd2($localtempfile);
                 } else {
                     if ($suffix == "wbmp") {
                         $im = @imagecreatefromwbmp($localtempfile);
                     }
                 }
             }
         }
     }
 }
 mysqltest();
 if (!$im) {
     $output = "." . $thumb_folder . "/dummy.png";
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:31,代码来源:index_media.php

示例11: imagecreatefrombmp

 function imagecreatefrombmp($filename)
 {
     //Create image from BMP
     $this->debug("Execute function: <b>imagecreatefrombmp</b><br/>");
     $tmp_name = tempnam("/tmp", "GD");
     $this->debug("Filename: <b>" . $filename . "</b><br/>");
     $this->debug("Tempfilename: <b>" . $tmp_name . "</b><br/>");
     if ($this->ConvertBMP2GD($filename, $tmp_name)) {
         $img = imagecreatefromgd($tmp_name);
         unlink($tmp_name);
         $this->debug("ConvertBMP2GD successful execution");
         return $img;
     }
     $this->debug("<font color=\"#FF0000\"><b>ConvertBMP2GD</b></font> failed!");
     return false;
 }
开发者ID:voguegroup,项目名称:moxhullmc,代码行数:16,代码来源:incResize.php

示例12: show_plain

     if (function_exists("imagecreatefromxbm")) {
         $img = @imagecreatefromxbm($file);
     } else {
         show_plain($file);
     }
     break;
 case 'xpm':
     if (function_exists("imagecreatefromxpm")) {
         $img = @imagecreatefromxpm($file);
     } else {
         show_plain($file);
     }
     break;
 case 'gd':
     if (function_exists("imagecreatefromgd")) {
         $img = @imagecreatefromgd($file);
     } else {
         show_plain($file);
     }
     break;
 case 'gd2':
     if (function_exists("imagecreatefromgd2")) {
         $img = @imagecreatefromgd2($file);
     } else {
         show_plain($file);
     }
     break;
 default:
     //we are not stupid...
     header("Content-type: text/html");
     echo "<html><head></head><body>Not an image</body></html>";
开发者ID:neymanna,项目名称:fusionforge,代码行数:31,代码来源:ImageTile.php

示例13: dirname

<?php

$cwd = dirname(__FILE__);
echo "JPEG to GD1 conversion: ";
echo imagegd(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "JPEG to GD2 conversion: ";
echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
echo "GD1 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed';
echo "\n";
echo "GD2 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
@unlink($cwd . "/test_gd1.jpeg");
@unlink($cwd . "/test_gd2.jpeg");
开发者ID:badlamer,项目名称:hhvm,代码行数:19,代码来源:jpg2gd.php

示例14: load

 private function load($path, $type)
 {
     $image = null;
     // jpeg
     if (function_exists('imagecreatefromjpeg') && ($type == 'image/jpg' || $type == 'image/jpeg' || $type == 'image/pjpeg')) {
         $image = @imagecreatefromjpeg($path);
         if ($image !== false) {
             return $image;
         }
     }
     // png
     if (function_exists('imagecreatefrompng') && ($type == 'image/png' || $type == 'image/x-png')) {
         $image = @imagecreatefrompng($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gif
     if (function_exists('imagecreatefromgif') && $type == 'image/gif') {
         $image = @imagecreatefromgif($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gd
     if (function_exists('imagecreatefromgd')) {
         $image = imagecreatefromgd($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gd2
     if (function_exists('imagecreatefromgd2')) {
         $image = @imagecreatefromgd2($path);
         if ($image !== false) {
             return $image;
         }
     }
     // bmp
     if (function_exists('imagecreatefromwbmp')) {
         $image = @imagecreatefromwbmp($path);
         if ($image !== false) {
             return $image;
         }
     }
     return $image;
 }
开发者ID:3116246,项目名称:haolinju,代码行数:47,代码来源:Gd.php

示例15: _openImage

 /**
  * Open image file
  */
 function _openImage($file)
 {
     # JPEG:
     $im = @imagecreatefromjpeg($file);
     if ($im !== false) {
         return $im;
     }
     # GIF:
     $im = @imagecreatefromgif($file);
     if ($im !== false) {
         return $im;
     }
     # PNG:
     $im = @imagecreatefrompng($file);
     if ($im !== false) {
         return $im;
     }
     # GD File:
     $im = @imagecreatefromgd($file);
     if ($im !== false) {
         return $im;
     }
     # GD2 File:
     $im = @imagecreatefromgd2($file);
     if ($im !== false) {
         return $im;
     }
     # WBMP:
     $im = @imagecreatefromwbmp($file);
     if ($im !== false) {
         return $im;
     }
     # XBM:
     $im = @imagecreatefromxbm($file);
     if ($im !== false) {
         return $im;
     }
     # XPM:
     $im = @imagecreatefromxpm($file);
     if ($im !== false) {
         return $im;
     }
     # Try and load from string:
     $im = @imagecreatefromstring(file_get_contents($file));
     if ($im !== false) {
         return $im;
     }
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:51,代码来源:avatar.php


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