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


PHP ImageGif函数代码示例

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


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

示例1: courierimage

function courierimage($char, $width = 8, $height = 12, $pdir = 'patterns/')
{
    $im = imagecreate($width, $height);
    $background_color = imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 0, 0, 0);
    imagettftext($im, 10, 0, 0, 10, $text_color, 'cour.ttf', $char);
    $imgarray_0 = img2array($im, $width, $height);
    $imgarray_1 = img_array_split($imgarray_0);
    $imgarray_2 = img_array_split($imgarray_1);
    $ia2name = img_array_name($imgarray_2);
    if (!file_exists($pdir . $ia2name)) {
        mkdir($pdir . $ia2name);
    }
    $ia1name = img_array_name($imgarray_1);
    if (!file_exists($pdir . $ia2name . '/' . $ia1name)) {
        mkdir($pdir . $ia2name . '/' . $ia1name);
    }
    $ia0name = img_array_name($imgarray_0);
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.txt';
    if (!file_exists($filename)) {
        // $handle = fopen($filename,'w');
        writeUTF8File($filename, $char);
    }
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.gif';
    if (!file_exists($filename)) {
        ImageGif($im, $filename);
        chmod($filename, 0777);
    }
    echo '<table><tr><td>' . print_img_array($imgarray_0) . '</td><td>' . print_img_array($imgarray_1) . '</td><td>' . print_img_array($imgarray_2) . "</td><td><img src=\"{$filename}\" /></td></table>";
}
开发者ID:andrewsalveson,项目名称:asciirender,代码行数:30,代码来源:test.php

示例2: courierimage

function courierimage($char, $width = 8, $height = 12, $pdir = 'patterns/')
{
    $im = imagecreate($width, $height);
    $background_color = imagecolorallocate($im, 255, 255, 255);
    $text_color = imagecolorallocate($im, 0, 0, 0);
    $imchar = $char;
    $imchar = mb_encode_numericentity($imchar, array(0x0, 0xffff, 0, 0xffff), 'UTF-8');
    // echo $imchar;
    imagettftext($im, 10, 0, 0, 10, $text_color, 'cour.ttf', $imchar);
    $imgarray_0 = img2array($im, $width, $height);
    $imgarray_1 = img_array_split($imgarray_0);
    $imgarray_2 = img_array_split($imgarray_1);
    $ia2name = img_array_name($imgarray_2);
    if (!file_exists($pdir . $ia2name)) {
        mkdir($pdir . $ia2name);
    }
    $ia1name = img_array_name($imgarray_1);
    if (!file_exists($pdir . $ia2name . '/' . $ia1name)) {
        mkdir($pdir . $ia2name . '/' . $ia1name);
    }
    $ia0name = img_array_name($imgarray_0);
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.txt';
    if (!file_exists($filename)) {
        writeUTF8File($filename, $char);
    }
    $filename = $pdir . $ia2name . '/' . $ia1name . '/' . $ia0name . '.gif';
    if (!file_exists($filename)) {
        ImageGif($im, $filename);
        chmod($filename, 0777);
    }
    // echo '<table><tr><td>'.print_img_array($imgarray_0).'</td><td>'.print_img_array($imgarray_1).'</td><td>'.print_img_array($imgarray_2)."</td><td><img src=\"$filename\" /></td></table>";
}
开发者ID:andrewsalveson,项目名称:asciirender,代码行数:32,代码来源:unicoderender.php

示例3: ResizeImage

function ResizeImage($Filename, $Thumbnail, $Size)
{
    $Path = pathinfo($Filename);
    $Extension = $Path['extension'];
    $ImageData = @GetImageSize($Filename);
    $Width = $ImageData[0];
    $Height = $ImageData[1];
    if ($Width >= $Height and $Width > $Size) {
        $NewWidth = $Size;
        $NewHeight = $Size / $Width * $Height;
    } elseif ($Height >= $Width and $Height > $Size) {
        $NewWidth = $Size / $Height * $Width;
        $NewHeight = $Size;
    } else {
        $NewWidth = $Width;
        $NewHeight = $Height;
    }
    $NewImage = @ImageCreateTrueColor($NewWidth, $NewHeight);
    if (preg_match('/^gif$/i', $Extension)) {
        $Image = @ImageCreateFromGif($Filename);
    } elseif (preg_match('/^png$/i', $Extension)) {
        $Image = @ImageCreateFromPng($Filename);
    } else {
        $Image = @ImageCreateFromJpeg($Filename);
    }
    if ($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG) {
        $TransIndex = imagecolortransparent($Image);
        // If we have a specific transparent color
        if ($TransIndex >= 0) {
            // Get the original image's transparent color's RGB values
            $TransColor = imagecolorsforindex($Image, $TransIndex);
            // Allocate the same color in the new image resource
            $TransIndex = imagecolorallocate($NewImage, $TransColor['red'], $TransColor['green'], $TransColor['blue']);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $TransIndex);
            // Set the background color for new image to transparent
            imagecolortransparent($NewImage, $TransIndex);
        } elseif ($ImageData[2] == IMAGETYPE_PNG) {
            // Turn off transparency blending (temporarily)
            imagealphablending($NewImage, false);
            // Create a new transparent color for image
            $color = imagecolorallocatealpha($NewImage, 0, 0, 0, 127);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $color);
            // Restore transparency blending
            imagesavealpha($NewImage, true);
        }
    }
    @ImageCopyResampled($NewImage, $Image, 0, 0, 0, 0, $NewWidth, $NewHeight, $Width, $Height);
    if (preg_match('/^gif$/i', $Extension)) {
        @ImageGif($NewImage, $Thumbnail);
    } elseif (preg_match('/^png$/i', $Extension)) {
        @ImagePng($NewImage, $Thumbnail);
    } else {
        @ImageJpeg($NewImage, $Thumbnail);
    }
    @chmod($Thumbnail, 0644);
}
开发者ID:kelsh,项目名称:classic,代码行数:58,代码来源:notgallery.php

示例4: gif

function gif($panels, $name)
{
    if (count($panels) > 0) {
        echo "Les images générées vont être enregistrées au format GIF.\n";
    }
    $i = 0;
    while (isset($panels[$i])) {
        ImageGif($panels[$i], $name . $i . ".gif");
        $i++;
    }
}
开发者ID:amira-s,项目名称:etna-projects,代码行数:11,代码来源:saveimg.php

示例5: Error

function Error()
{
    header('Content-Type: image/gif');
    header('Content-Disposition: inline; filename="fakeapple.gif"');
    $blank = 'R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
    // A transparent 1x1 GIF image
    $image = ImageCreateFromString(base64_decode($blank));
    ImageGif($image);
    ImageDestroy($image);
    die;
}
开发者ID:vinorodrigues,项目名称:wpts-favicons,代码行数:11,代码来源:fakeapple.php

示例6: IndexAction

 function IndexAction()
 {
     $str = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 4));
     $_SESSION['VerifyCode'] = strtolower(implode('', $code));
     $width = 115;
     $height = 29;
     $im = ImageCreate($width, $height);
     // 创建图形
     ImageColorAllocate($im, 255, 255, 255);
     // 填充背景颜色为白色
     // 用淡色给图形添加杂色
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($im, 230, 104, 66);
         ImageSetPixel($im, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     // 用深色调绘制边框
     $bordercolor = ImageColorAllocate($im, 255, 255, 255);
     ImageRectangle($im, 0, 0, $width - 1, $height - 1, $bordercolor);
     $offset = rand(10, 30);
     $font = array('View/font/UniversityRomanStd.otf');
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 106);
         shuffle($font);
         imagettftext($im, 22, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += $width / 5 - rand(0, 2);
     }
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 5));
     // 干扰字符
     $offset = rand(10, 30);
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 66);
         shuffle($font);
         imagettftext($im, 8, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += rand(5, 10);
     }
     // 禁止缓存
     header("pragma:no-cache\r\n");
     header("Cache-Control:no-cache\r\n");
     header("Expires:0\r\n");
     if (ImageTypes() & IMG_PNG) {
         header('Content-Type:image/png');
         ImagePNG($im);
     } elseif (ImageTypes() & IMG_JPEG) {
         header('Content-Type:image/jpeg');
         ImageJPEG($im);
     } else {
         header('Content-Type:image/gif');
         ImageGif($im);
     }
 }
开发者ID:logdns,项目名称:amh-4.2,代码行数:53,代码来源:VerifyCode.php

示例7: SetImgSize

function SetImgSize($img, $W = 0, $H = 0, $Key = 1)
{
    //echo("$img , $W ,$H , $Key");
    $rasshr = substr(strrchr($img, '.'), 1);
    //организация работы с форматами GIF JPEG PNG
    switch ($rasshr) {
        default:
        case "gif":
            $srcImage = @ImageCreateFromGIF($img);
            break;
        case "jpg":
            $srcImage = @ImageCreateFromJPEG($img);
            break;
        case "png":
            $srcImage = @ImageCreateFromPNG($img);
            break;
    }
    //определяем изначальную длинну и высоту
    $srcWidth = @ImageSX($srcImage);
    $srcHeight = @ImageSY($srcImage);
    //ресайз по заданной ширине
    if ($W != 0 && $H == 0 && $W < $srcWidth) {
        $res = ResNoDel($srcWidth, $srcHeight, $W, 0);
    }
    //ресайз по заданной высоте
    if ($W == 0 && $H != 0 && $H < $srcHeight) {
        $res = ResNoDel($srcWidth, $srcHeight, 0, $H);
    }
    //ресайз с обрезкой
    if ($W != 0 && $H != 0 && ($H < $srcHeight || $W < $srcWidth)) {
        $res = ResDel($srcWidth, $srcHeight, min($W, $srcWidth), min($H, $srcHeight), $Key);
    }
    //создаем картинку
    if ($res) {
        $endImage = @ImageCreateTrueColor($res[2], $res[3]);
        ImageCopyResampled($endImage, $srcImage, 0, 0, $res[0], $res[1], $res[2], $res[3], $res[4], $res[5]);
        unlink($img);
        switch ($rasshr) {
            case "gif":
                ImageGif($endImage, $img);
                break;
            default:
            case "jpg":
                imagejpeg($endImage, $img);
                break;
            case "png":
                imagepng($endImage, $img);
                break;
        }
        ImageDestroy($endImage);
    }
}
开发者ID:bonvio-opr,项目名称:CMS,代码行数:52,代码来源:_function.php

示例8: ShowImageHeader

function ShowImageHeader($ImageHandle)
{
    if (ImageTypes() & IMG_PNG) {
        Header("Content-type: image/png");
        ImagePng($ImageHandle);
    } elseif (ImageTypes() & IMG_GIF) {
        Header("Content-type: image/gif");
        ImageGif($ImageHandle);
    } elseif (ImageTypes() & IMG_JPEG) {
        Header("Content-type: image/jpeg");
        ImageJpeg($ImageHandle, "", 0.5);
    } else {
        die("No images support");
    }
    ImageDestroy($ImageHandle);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:img.php

示例9: gif

 public static function gif($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE)
 {
     $image = self::image($frame, $pixelPerPoint, $outerFrame);
     if ($filename === false) {
         Header("Content-type: image/gif");
         ImageGif($image);
     } else {
         if ($saveandprint === TRUE) {
             ImageGif($image, $filename);
             header("Content-type: image/gif");
             ImageGif($image);
         } else {
             ImageGif($image, $filename);
         }
     }
     ImageDestroy($image);
 }
开发者ID:WeaponsDivision,项目名称:PHPQRCode,代码行数:17,代码来源:QRimage.php

示例10: saveImageInFormat

function saveImageInFormat($imageResized, $newImageName, $file_format = null)
{
    // right now this only supports gif/jpg/jpeg
    if (!$file_format) {
        $file_format = getFileExtension($newImageName);
    }
    switch ($file_format) {
        case "gif":
            header('Content-Type: image/gif');
            ImageGif($imageResized, $newImageName);
            imagedestroy($imageResized);
            // free up memory
            break;
        case "jpg":
        case "jpeg":
            header('Content-Type: image/jpeg');
            ImageJpeg($imageResized, $newImageName);
            imagedestroy($imageResized);
            break;
    }
}
开发者ID:highchair,项目名称:hcd-trunk,代码行数:21,代码来源:image.php

示例11: DImage

function DImage($img_src, $img_dest, $max_w = 120, $max_h = 90, $qualite = 80, $crop_from_center = 0)
{
    //ne lit pas l'image source !
    if (!function_exists('ImageCreateTrueColor')) {
        return 0;
    }
    if (!is_file($img_src)) {
        db("!is_file({$img_src})");
        return;
    }
    $startX = $startY = 0;
    #return;
    $size = @GetImageSize($img_src);
    $src_w = $size[0];
    $src_h = $size[1];
    $type = $size[2];
    $ratio = @round($src_w / $src_h, 2);
    #$_ENV['db'].="<li>".pre($size);
    if ($max_w > $src_w) {
        copy($img_src, $img_dest);
        return;
    }
    #ne pas redimensioner si plus petit
    $ratiom = round($max_w / $max_h, 2);
    if ($ratio > $ratiom) {
        $dst_w = $max_w;
        $dst_h = ceil($max_w / $ratio);
    } else {
        $dst_h = $max_h;
        $dst_w = ceil($max_h * $ratio);
    }
    #if($dst_w==0){$_GET[debug].="<li>$img_dest  $ratio> $ratiom? $dst_w $dst_h".($max_h*$rationm);return;}
    gt();
    $dst_im = ImageCreateTrueColor($dst_w, $dst_h);
    // Copie dedans l'image initiale redimensionnée
    if (!$dst_im) {
        $_ENV['db'] .= "<li>{$img_dest}  {$ratio}> {$ratiom}?  {$type}--- FAIL {$dst_w} {$dst_h}";
        return;
    }
    switch ($type) {
        case 3:
            $src_im = @ImageCreateFromPng($img_src);
            break;
        case 2:
            $src_im = @ImageCreateFromJpeg($img_src);
            break;
        case 1:
            $src_im = @ImageCreateFromGif($img_src);
            break;
    }
    if (!$src_im) {
        echo "{$img_src},{$img_dest},{$dst_w},{$dst_h},{$type},{$src_w},{$src_h}, {$type},<hr>Erreur d'upload de photo pour cause de Format JPEG Pourri !";
    }
    ReMapTree($img_dest);
    if (imagecopyresized($dst_im, $src_im, 0, 0, $startX, $startY, $dst_w, $dst_h, $src_w, $src_h)) {
        $_ENV['db'] .= " Miniature Générée";
    }
    //RESIZE TO 640 ELSE INCLUS
    switch ($type) {
        case 1:
            ImageGif($dst_im, $img_dest);
            break;
        case 2:
            ImageJpeg($dst_im, $img_dest, $qualite);
            break;
        case 3:
            ImagePng($dst_im, $img_dest, 9);
            break;
    }
    ImageDestroy($dst_im);
    ImageDestroy($src_im);
    $_ENV['db'] .= "<li>{$dst_w},{$dst_h},{$src_w},{$src_h} {$img_dest} {$ratiom}={$ratio} {$type} -";
    return;
    // Détruis les tampons
}
开发者ID:Ben749,项目名称:racetrack,代码行数:75,代码来源:deprecated.php

示例12: _flipGif

 function _flipGif()
 {
     $source = ImagecreateFromGif($this->_source);
     $width = imagesx($source);
     $height = imagesy($source);
     $image = ImageCreateTrueColor($width, $height);
     if ($this->_hori) {
         for ($i = 0; $i < $width; $i++) {
             ImageCopyResampled($image, $source, $width - $i - 1, 0, $i, 0, 1, $height, 1, $height);
         }
         if ($this->_vert) {
             ImageCopyResampled($source, $image, 0, 0, 0, 0, $width, $height, $width, $height);
         }
     }
     if ($this->_vert) {
         for ($i = 0; $i < $height; $i++) {
             ImageCopyResampled($image, $source, 0, $height - $i - 1, 0, $i, $width, 1, $width, 1);
         }
     }
     ImageDestroy($source);
     $result = ImageGif($image, $this->_target);
     ImageDestroy($image);
     return $result;
 }
开发者ID:uksubs66,项目名称:java-v2,代码行数:24,代码来源:MCImageToolsGD.php

示例13: Header

$phpgw_info["flags"]["noheader"] = True;
include "../header.inc.php";
Header("Content-type: image/gif");
$border = 1;
//echo $filename;
$im = openGif($filename);
/* Open the provided file */
$bg = getRGB($phpgw_info["theme"]["navbar_bg"]);
/* get navbar theme */
$fg = getRGB($phpgw_info["theme"]["navbar_text"]);
$navbar_bg = ImageColorAllocate($im, $bg["r"], $bg["g"], $bg["b"]);
$navbar_fg = ImageColorAllocate($im, $fg["r"], $fg["g"], $fg["b"]);
$dk_gray = ImageColorAllocate($im, 128, 128, 128);
$lt_gray = ImageColorAllocate($im, 192, 192, 192);
$dx = ImageSX($im);
/* get image size */
$dy = ImageSY($im);
ImageFilledRectangle($im, 0, 0, $dx, $border, $dk_gray);
/* top */
ImageFilledRectangle($im, 0, 0, $border, $dy, $dk_gray);
/* left */
ImageFilledRectangle($im, $dx - $border - 1, 0, $dx, $dy, $lt_gray);
/* right */
ImageFilledRectangle($im, 0, $dy - $border - 1, $dx, $dy, $lt_gray);
/* bottom */
//ImageGif($im,"$DOCUMENT_ROOT/kb/xml/$filename");
ImageGif($im);
ImageDestroy($im);
?>

开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:29,代码来源:navbar-sel.php

示例14: imagemake

 /**
  * Write the icon in $im pointer to $path
  *
  * @param pointer $im Pointer to GDlib image resource
  * @param string $path Absolute path to the filename in which to write the icon.
  * @return void
  * @access private
  */
 public static function imagemake($im, $path)
 {
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
         @ImagePng($im, $path);
     } else {
         @ImageGif($im, $path);
     }
     if (@is_file($path)) {
         GeneralUtility::fixPermissions($path);
     }
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:19,代码来源:IconUtility.php

示例15: save

 /**
  * image::save()
  * 
  * @param mixed $path
  * @param string $newname
  * @param integer $quality
  * @return
  */
 function save($path, $newname = '', $quality = 100)
 {
     if (empty($this->error)) {
         if ($this->is_destroy) {
             $this->get_createImage();
         }
         if (is_dir($path) and is_writeable($path)) {
             if (empty($newname)) {
                 $newname = $this->create_Image_info['width'] . '_' . $this->create_Image_info['height'];
                 if (defined('PATHINFO_FILENAME')) {
                     $basename = pathinfo($this->create_Image_info['src'], PATHINFO_FILENAME);
                 } else {
                     $basename = strstr($this->create_Image_info['src'], '.') ? substr($this->create_Image_info['src'], 0, strrpos($this->create_Image_info['src'], '.')) : "";
                 }
                 if (!empty($basename)) {
                     $newname .= '_' . $basename;
                 }
             }
             $newname = preg_replace('/^\\W+|\\W+$/', '', $newname);
             $newname = preg_replace('/\\s+/', '_', $newname);
             $newname = strtolower(preg_replace('/\\W-/', '', $newname));
             $newname = preg_replace("/." . $this->create_Image_info['ext'] . "\$/", '', $newname);
             if (!preg_match("/\\/\$/", $path)) {
                 $path = $path . "/";
             }
             $newname = $path . $newname . '.' . $this->create_Image_info['ext'];
             switch ($this->create_Image_info['type']) {
                 case 'IMAGETYPE_GIF':
                     ImageGif($this->createImage, $newname);
                     break;
                 case 'IMAGETYPE_JPEG':
                     ImageJpeg($this->createImage, $newname, $quality);
                     break;
                 case 'IMAGETYPE_PNG':
                     ImagePng($this->createImage, $newname);
             }
             $this->create_Image_info['src'] = $newname;
         }
         $this->Destroy();
     }
 }
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:49,代码来源:image.class.php


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