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

PHP imagegif函数代码示例

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

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



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

示例1: generate

 public function generate(array $array)
 {
     $frames = array();
     $frame_delay = array();
     foreach ($array['frames'] as $frame) {
         $image = $this->_createImage($frame['image']);
         if (array_key_exists('text', $frame)) {
             foreach ($frame['text'] as $text) {
                 // Set defaults
                 $defaults = array("angle" => $this->_defaultAngle, "fonts" => $this->_defaultFont, "fonts-color" => $this->_defaultFontColor, "fonts-size" => $this->_defaultFontSize, "y-position" => $this->_defaultYPosition, "x-position" => $this->_defaultXPosition, "text" => null, "letter-spacing" => 0);
                 // Overwrite all the defaults with the arguments
                 $args = array_merge($defaults, $text);
                 $fontColor = is_array($args['fonts-color']) ? $args['fonts-color'] : $this->_hex2rgb($args['fonts-color']);
                 $text_color = imagecolorallocate($image, $fontColor[0], $fontColor[1], $fontColor[2]);
                 $this->imagettftextSp($image, $args['fonts-size'], $args['angle'], $args['x-position'], $args['y-position'], $text_color, $args['fonts'], $args['text'], $args['letter-spacing']);
             }
         }
         $delay = array_key_exists('delay', $frame) ? $frame['delay'] : $this->_defaultDelay;
         ob_start();
         imagegif($image);
         $frames[] = ob_get_contents();
         $frame_delay[] = $delay;
         // Delay in the animation.
         ob_end_clean();
     }
     $repeat = array_key_exists('repeat', $array) ? $array['repeat'] : $this->_defaultRepeat;
     $gif = new GIFEncoder($frames, $frame_delay, $repeat, 2, 0, 0, 0, 0, 'bin');
     return $gif->GetAnimation();
 }
开发者ID:Schnitzel,项目名称:php-gif,代码行数:29,代码来源:GIFGenerator.class.php


示例2: fit

 /**
  * Fit small image to specified bound
  *
  * @param string $src
  * @param string $dest
  * @param int $width
  * @param int $height
  * @return bool
  */
 public function fit($src, $dest, $width, $height)
 {
     // Calculate
     $size = getimagesize($src);
     $ratio = max($width / $size[0], $height / $size[1]);
     $old_width = $size[0];
     $old_height = $size[1];
     $new_width = intval($old_width * $ratio);
     $new_height = intval($old_height * $ratio);
     // Resize
     @ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT));
     $image = imagecreatefromstring(file_get_contents($src));
     $new_image = wp_imagecreatetruecolor($new_width, $new_height);
     imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
     if (IMAGETYPE_PNG == $size[2] && function_exists('imageistruecolor') && !imageistruecolor($image)) {
         imagetruecolortopalette($new_image, false, imagecolorstotal($image));
     }
     // Destroy old image
     imagedestroy($image);
     // Save
     switch ($size[2]) {
         case IMAGETYPE_GIF:
             $result = imagegif($new_image, $dest);
             break;
         case IMAGETYPE_PNG:
             $result = imagepng($new_image, $dest);
             break;
         default:
             $result = imagejpeg($new_image, $dest);
             break;
     }
     imagedestroy($new_image);
     return $result;
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:43,代码来源:Image.php


示例3: render

 /**
  * Displays the image
  *
  * @param	integer	$quality	image render quality 1-100, default 100
  * @access	public
  * @return	void
  */
 function render($quality = 100)
 {
     header('Content-type: image/' . $this->type);
     @imageinterlace($this->handle, 1);
     @imagegif($this->handle, NULL, $quality);
     @imagedestroy($this->handle);
 }
开发者ID:sauruscms,项目名称:Saurus-CMS-Community-Edition,代码行数:14,代码来源:GotchaGIF.class.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: return_image

function return_image($boolean)
{
    if (function_exists('imagecreate')) {
        $im = imagecreate(1, 1);
        if ($boolean) {
            imagecolorallocate($im, 0, 255, 0);
        } else {
            imagecolorallocate($im, 255, 0, 0);
        }
        header("Content-type: image/gif");
        imagegif($im);
        imagedestroy($im);
    } else {
        $grape_gif = '
        R0lGODlhIAAgALMAAAAAAAAAgHCAkC6LV76+vvXeswD/ANzc3DLNMubm+v/6zS9PT6Ai8P8A////
        /////yH5BAEAAAkALAAAAAAgACAAAAS00MlJq7046803AF3ofAYYfh8GIEvpoUZcmtOKAO5rLMva
        0rYVKqX5IEq3XDAZo1GGiOhw5rtJc09cVGo7orYwYtYo3d4+DBxJWuSCAQ30+vNTGcxnOIARj3eT
        YhJDQ3woDGl7foNiKBV7aYeEkHEignKFkk4ciYaImJqbkZ+PjZUjaJOElKanqJyRrJyZgSKkokOs
        NYa2q7mcirC5I5FofsK6hcHHgsSgx4a9yzXK0rrV19gRADs=
        ';
        $php_rules = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
        if ($boolean) {
            $data = base64_decode($grape_gif);
            header("Content-type: image/gif");
        } else {
            $data = base64_decode($php_rules);
            header("Content-type: image/png");
        }
        echo $data;
    }
}
开发者ID:zivkovicp,项目名称:genetify,代码行数:31,代码来源:init.php


示例6: createThumb

 /**
  * Create thumbnail image by php using the GD Library
  *
  * @since   1.0.0
  */
 public static function createThumb($source_image, $destination_image_url, $width, $height, $quality, $crop = null, $prefix = null, $checksize = null)
 {
     //Set image ratio
     list($w, $h) = getimagesize($source_image);
     // resize
     if ($crop === true) {
         if ($checksize && ($w < $width or $h < $height)) {
             $width = $w + 1;
             $height = $h + 1;
             $x = 0;
         } else {
             $ratio = max($width / $w, $height / $h);
             $h = $height / $ratio;
             $x = ($w - $width / $ratio) / 2;
             $w = $width / $ratio;
         }
     } else {
         if ($checksize && ($w < $width or $h < $height)) {
             $width = $w;
             $height = $h;
             $x = 0;
         } else {
             $ratio = min($width / $w, $height / $h);
             $width = $w * $ratio;
             $height = $h * $ratio;
             $x = 0;
         }
     }
     if (preg_match("/.jpg/i", "{$source_image}") or preg_match("/.jpeg/i", "{$source_image}")) {
         //JPEG type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefromjpeg($source_image);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         imagejpeg($destImage, $destination_image_url, $quality);
         imagedestroy($destImage);
     } elseif (preg_match("/.png/i", "{$source_image}")) {
         //PNG type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefrompng($source_image);
         imagealphablending($destImage, false);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         imagesavealpha($destImage, true);
         imagepng($destImage, $destination_image_url);
     } elseif (preg_match("/.gif/i", "{$source_image}")) {
         //GIF type thumbnail
         $destImage = imagecreatetruecolor($width, $height);
         $sourceImage = imagecreatefromgif($source_image);
         $bgc = imagecolorallocate($destImage, 255, 255, 255);
         imagefilledrectangle($destImage, 0, 0, $width, $height, $bgc);
         imagecopyresampled($destImage, $sourceImage, 0, 0, $x, 0, $width, $height, $w, $h);
         if (function_exists('imagegif')) {
             // Pour GIF
             header('Content-Type: image/gif');
             imagegif($destImage, $destination_image_url, $quality);
         }
         imagedestroy($destImage);
     } else {
         echo 'unable to load image source';
     }
 }
开发者ID:esorone,项目名称:efcpw,代码行数:65,代码来源:create.php


示例7: resizeAndSaveImage

 public function resizeAndSaveImage($mimeType, $source_url, $destination_url)
 {
     // initial image buffer
     if ($mimeType == 'image/jpeg') {
         $image = imagecreatefromjpeg($source_url);
     } elseif ($mimeType == 'image/gif') {
         $image = imagecreatefromgif($source_url);
     } elseif ($mimeType == 'image/png') {
         $image = imagecreatefrompng($source_url);
     }
     // calc new image size keep aspect ratio
     $original_width = imagesx($image);
     $original_height = imagesy($image);
     // if current image is bigger then 500px, resize it to make it smaller
     $new_width = 500;
     if ($original_width > $new_width) {
         // calc new height by keep aspect ratio
         $new_height = $this->getResizeHeightByWidth($original_height, $original_width, $new_width);
         // resize with image buffer
         $new_image = imagecreatetruecolor($new_width, $new_height);
         imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $original_width, $original_height);
         // saving image as full-alpha
         imagealphablending($new_image, false);
         imagesavealpha($new_image, true);
         if ($mimeType == 'image/jpeg') {
             imagejpeg($new_image, $source_url);
         } elseif ($mimeType == 'image/gif') {
             imagegif($new_image, $source_url);
         } elseif ($mimeType == 'image/png') {
             imagepng($new_image, $source_url);
         }
         imagedestroy($new_image);
     }
     imagedestroy($image);
 }
开发者ID:edisonthk,项目名称:cv_api,代码行数:35,代码来源:UploadService.php


示例8: output

 /**
  * Output an image. If the image is true-color, it will be converted
  * to a paletted image first using imagetruecolortopalette().
  *
  * @param   resource handle
  * @return  bool
  */
 public function output($handle)
 {
     if (imageistruecolor($handle)) {
         imagetruecolortopalette($handle, $this->dither, $this->ncolors);
     }
     return imagegif($handle);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:GifStreamWriter.class.php


示例9: resample

function resample()
{
    // $filename = "$path.'/'.$filename";
    $size = getimagesize($path . '/' . $filename);
    list($width, $height) = $size;
    $new_width = 100;
    $new_height = 100;
    $new_image = imagecreatetruecolor($new_width, $new_height);
    // 判断格式
    if ($hz == 'jpg') {
        $image = imagecreatefromjpeg($path . '/' . $filename);
    } elseif ($hz == 'png') {
        $image = imagecreatefrompng($path . '/' . $filename);
    } else {
        $image = imagecreatefromgif($path . '/' . $filename);
    }
    // $image = imagecreatefromjpeg($filename);
    imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    // 判断格式
    if ($hz == 'jpg') {
        imagejpeg($new_image, $path . '/' . $filename . 'R', 100);
    } elseif ($hz == 'png') {
        imagepng($new_image, $path . '/' . $filename . 'R', 100);
    } else {
        imagegif($new_image, $path . '/' . $filename . 'R', 100);
    }
    // imagejpeg($new_image, 'new.jpg', 100);
    imagedestroy($new_image);
    imagedestroy($image);
}
开发者ID:ClarifyingYAN,项目名称:redrock-homewok,代码行数:30,代码来源:resample.php


示例10: resize

function resize($width, $height)
{
    list($w, $h) = getimagesize($_FILES['image']['tmp_name']);
    $ratio = max($width / $w, $height / $h);
    $h = ceil($height / $ratio);
    $x = ($w - $width / $ratio) / 2;
    $w = ceil($width / $ratio);
    $path = 'photos/' . $width . 'x' . $height . '_' . $_FILES['image']['name'];
    $imgString = file_get_contents($_FILES['image']['tmp_name']);
    $image = imagecreatefromstring($imgString);
    $tmp = imagecreatetruecolor($width, $height);
    imagecopyresampled($tmp, $image, 0, 0, $x, 0, $width, $height, $w, $h);
    /* Save image */
    switch ($_FILES['image']['type']) {
        case 'image/jpeg':
            imagejpeg($tmp, $path, 100);
            break;
        case 'image/png':
            imagepng($tmp, $path, 0);
            break;
        case 'image/gif':
            imagegif($tmp, $path);
            break;
        default:
            exit;
            break;
    }
    return $path;
    /* cleanup memory */
    imagedestroy($image);
    imagedestroy($tmp);
}
开发者ID:boundforglory1995,项目名称:Wall,代码行数:32,代码来源:addexec.php


示例11: img_resize

function img_resize($src, $dest, $width, $height, $rgb = 0xffffff, $quality = 100)
{
    if (!file_exists($src)) {
        return false;
    }
    $size = getimagesize($src);
    if ($size === false) {
        return false;
    }
    $format = strtolower(substr($size['mime'], strpos($size['mime'], '/') + 1));
    $icfunc = 'imagecreatefrom' . $format;
    if (!function_exists($icfunc)) {
        return false;
    }
    $x_ratio = $width / $size[0];
    $y_ratio = $height / $size[1];
    if ($height == 0) {
        $y_ratio = $x_ratio;
        $height = $y_ratio * $size[1];
    } elseif ($width == 0) {
        $x_ratio = $y_ratio;
        $width = $x_ratio * $size[0];
    }
    $ratio = min($x_ratio, $y_ratio);
    $use_x_ratio = $x_ratio == $ratio;
    $new_width = $use_x_ratio ? $width : floor($size[0] * $ratio);
    $new_height = !$use_x_ratio ? $height : floor($size[1] * $ratio);
    $new_left = $use_x_ratio ? 0 : floor(($width - $new_width) / 2);
    $new_top = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2);
    // если не нужно увеличивать маленькую картинку до указанного размера
    if ($size[0] < $new_width && $size[1] < $new_height) {
        $width = $new_width = $size[0];
        $height = $new_height = $size[1];
    }
    $isrc = $icfunc($src);
    $idest = imagecreatetruecolor($width, $height);
    imagefill($idest, 0, 0, $rgb);
    imagecopyresampled($idest, $isrc, $new_left, $new_top, 0, 0, $new_width, $new_height, $size[0], $size[1]);
    $i = strrpos($dest, '.');
    if (!$i) {
        return '';
    }
    $l = strlen($dest) - $i;
    $ext = substr($dest, $i + 1, $l);
    switch ($ext) {
        case 'jpeg':
        case 'jpg':
            imagejpeg($idest, $dest, $quality);
            break;
        case 'gif':
            imagegif($idest, $dest);
            break;
        case 'png':
            imagepng($idest, $dest);
            break;
    }
    imagedestroy($isrc);
    imagedestroy($idest);
    return true;
}
开发者ID:Vovanostm,项目名称:site_stupen,代码行数:60,代码来源:resize_img.php


示例12: watermark

function watermark($image, $mimeType, $imgWidth, $imgHeight, $watermark, $watermarkHeight, $watermarkWidth, $position = "center")
{
    // Calculate the watermark position
    switch ($position) {
        case "center":
            $marginBottom = round($imgHeight / 2);
            $marginRight = round($imgWidth / 2) - round($watermarkWidth / 2);
            break;
        case "top-left":
            $marginBottom = round($imgHeight - $watermarkHeight);
            $marginRight = round($imgWidth - $watermarkWidth);
            break;
        case "bottom-left":
            $marginBottom = 5;
            $marginRight = round($imgWidth - $watermarkWidth);
            break;
        case "top-right":
            $marginBottom = round($imgHeight - $watermarkHeight);
            $marginRight = 5;
            break;
        default:
            $marginBottom = 2;
            $marginRight = 2;
            break;
    }
    $watermark = imagecreatefrompng($watermark);
    switch ($mimeType) {
        case "jpeg":
        case "jpg":
            $createImage = imagecreatefromjpeg($image);
            break;
        case "png":
            $createImage = imagecreatefrompng($image);
            break;
        case "gif":
            $createImage = imagecreatefromgif($image);
            break;
        default:
            $createImage = imagecreatefromjpeg($image);
            break;
    }
    $sx = imagesx($watermark);
    $sy = imagesy($watermark);
    imagecopy($createImage, $watermark, imagesx($createImage) - $sx - $marginRight, imagesy($createImage) - $sy - $marginBottom, 0, 0, imagesx($watermark), imagesy($watermark));
    switch ($mimeType) {
        case "jpeg":
        case "jpg":
            imagejpeg($createImage, $image);
            break;
        case "png":
            imagepng($createImage, $image);
            break;
        case "gif":
            imagegif($createImage, $image);
            break;
        default:
            throw new \Exception("A watermark can only be applied to: jpeg, jpg, gif, png images ");
            break;
    }
}
开发者ID:JoaoBGusmao,项目名称:qualdosdois,代码行数:60,代码来源:func.image-watermark.php


示例13: save

 /**
  * 图片保存方法
  * @param $fileName 保存路径
  * @return void
  */
 function save($fileName)
 {
     $this->saveCode();
     imagegif($this->validate, $fileName);
     imagedestroy($this->validate);
     imagedestroy($this->image);
 }
开发者ID:PoppyLi,项目名称:PCMS,代码行数:12,代码来源:captcha.php


示例14: save

 public function save($sFileName)
 {
     $sExt = strtolower(array_pop(explode('.', $sFileName)));
     if (!$sExt) {
         return false;
     }
     if (!in_array($sExt, $this->aImageTypes)) {
         return false;
     }
     $bResult = false;
     switch ($sExt) {
         case 'jpg':
         case 'jpeg':
             $bResult = imagejpeg($this->rRes, $sFileName, $this->nJpegQuality);
             break;
         case 'gif':
             $bResult = imagegif($this->rRes, $sFileName);
             break;
         case 'png':
             imagealphablending($this->rRes, false);
             imagesavealpha($this->rRes, true);
             $bResult = imagepng($this->rRes, $sFileName);
             break;
     }
     if (!$bResult) {
         return false;
     }
     return true;
 }
开发者ID:lstaszak,项目名称:zf_zk_aleph,代码行数:29,代码来源:Image.php


示例15: outputPreview

/**
*   @desc ������� ������ �����������
*   @return 
*/
function outputPreview($szContent, $szMime)
{
    $source = imagecreatefromstring($szContent);
    $nSourceHeight = imagesy($source);
    $nSourceWidth = imagesx($source);
    // �������� ������ � ������
    if (DAO_IMAGE_THUMBNAIL_X == 0) {
        $szHeight = DAO_IMAGE_THUMBNAIL_Y;
        $szWidth = intval($nSourceWidth * DAO_IMAGE_THUMBNAIL_Y / $nSourceHeight);
    } elseif (DAO_IMAGE_THUMBNAIL_Y == 0) {
        $szWidth = DAO_IMAGE_THUMBNAIL_X;
        $szHeight = intval($nSourceHeight * DAO_IMAGE_THUMBNAIL_X / $nSourceWidth);
    } else {
        $szWidth = DAO_IMAGE_THUMBNAIL_X;
        $szHeight = DAO_IMAGE_THUMBNAIL_Y;
    }
    $thumb = imagecreatetruecolor($szWidth, $szHeight);
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $szWidth, $szHeight, $nSourceWidth, $nSourceHeight);
    switch ($szMime) {
        case 'image/jpeg':
            imagejpeg($thumb);
            break;
        case 'image/png':
            imagepng($thumb);
            break;
        case 'image/gif':
            imagegif($thumb);
            break;
        default:
            imagejpeg($thumb);
    }
}
开发者ID:gudwin,项目名称:extasy,代码行数:36,代码来源:showimage.php


示例16: resize_image

function resize_image($src, $dest, $src_h, $src_w, $dest_h, $dest_w, $type, $src_x=0, $src_y=0) {
	$thumbnail_img = imagecreatetruecolor($dest_w, $dest_h);

	if ($type == 'gif') {
		$source = imagecreatefromgif($src);
	} else if ($type == 'jpg') {
		$source = imagecreatefromjpeg($src);
	} else {
		$source = imagecreatefrompng($src);
	}
	
	if ($src_x > 0 || $src_y > 0){
		imagecopyresized($thumbnail_img, $source, 0, 0, $src_x, $src_y, $dest_w, $dest_h, $src_w, $src_h);
	} else {
		imagecopyresampled($thumbnail_img, $source, $src_x, $src_y, 0, 0, $dest_w, $dest_h, $src_w, $src_h);
	}

	if ($type == 'gif') {
		imagegif($thumbnail_img, $dest);
	} else if ($type == 'jpg') {
		imagejpeg($thumbnail_img, $dest, 75);
	} else {
		imagepng($thumbnail_img, $dest, 7);
	}
}
开发者ID:radiocontrolled,项目名称:ATutor,代码行数:25,代码来源:profile_picture.php


示例17: resize

function resize($width, $height, $path, $i)
{
    /* Get original image x y*/
    list($w, $h) = getimagesize($_FILES['image']['tmp_name'][$i]);
    /* calculate new image size with ratio */
    $ratio = max($width / $w, $height / $h);
    $h = ceil($height / $ratio);
    $x = ($w - $width / $ratio) / 2;
    $w = ceil($width / $ratio);
    /* new file name */
    /* read binary data from image file */
    $imgString = file_get_contents($_FILES['image']['tmp_name'][$i]);
    /* create image from string */
    $image = imagecreatefromstring($imgString);
    $tmp = imagecreatetruecolor($width, $height);
    imagecopyresampled($tmp, $image, 0, 0, $x, 0, $width, $height, $w, $h);
    /* Save image */
    switch ($_FILES['image']['type'][$i]) {
        case 'image/jpeg':
            imagejpeg($tmp, $path, 100);
            break;
        case 'image/png':
            imagepng($tmp, $path, 0);
            break;
        case 'image/gif':
            imagegif($tmp, $path);
            break;
        default:
            return false;
            break;
    }
    imagedestroy($image);
    imagedestroy($tmp);
    return true;
}
开发者ID:phanduong2211,项目名称:phukienthoitranggiare,代码行数:35,代码来源:upload.blade.php


示例18: __resizeGif

 private function __resizeGif($original, $new_filename, $scaled_width, $scaled_height, $width, $height)
 {
     $error = false;
     if (!($src = imagecreatefromgif($original))) {
         $this->__errors[] = 'There was an error creating your resized image (gif).';
         $error = true;
     }
     if (!($tmp = imagecreatetruecolor($scaled_width, $scaled_height))) {
         $this->__errors[] = 'There was an error creating your true color image (gif).';
         $error = true;
     }
     if (!imagecopyresampled($tmp, $src, 0, 0, 0, 0, $scaled_width, $scaled_height, $width, $height)) {
         $this->__errors[] = 'There was an error creating your true color image (gif).';
         $error = true;
     }
     if (!($new_image = imagegif($tmp, $new_filename))) {
         $this->__errors[] = 'There was an error writing your image to file (gif).';
         $error = true;
     }
     imagedestroy($tmp);
     if (false == $error) {
         return $new_image;
     }
     return false;
 }
开发者ID:shivram2609,项目名称:e-leran,代码行数:25,代码来源:ImageComponent.php


示例19: index

 public function index()
 {
     header("content-type:image/gif");
     $this->load->library('session');
     $width = 60;
     $height = 30;
     $img = imagecreatetruecolor($width, $height);
     $white = imagecolorallocate($img, 255, 255, 255);
     $color = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
     $str = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $code = "";
     for ($i = 0; $i < 5; $i++) {
         $code .= $str[rand(0, strlen($str) - 1)];
     }
     $this->session->set_userdata(array('myCode' => strtolower($code)));
     imagefilledrectangle($img, 0, 0, 60, 30, $color);
     for ($i = 0; $i < 100; $i++) {
         imagesetpixel($img, rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
     }
     for ($i = 0; $i < 10; $i++) {
         imageline($img, rand(0, 60), rand(0, 30), rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
     }
     imagestring($img, 5, 10, 5, $code, $white);
     return imagegif($img);
     //imagedestroy($img);
 }
开发者ID:804485808,项目名称:local_motors,代码行数:26,代码来源:imgcode.php


示例20: GetImageGif

function GetImageGif($file, $width, $maxWidth, $maxHeight) {
	header("Content-type: image/gif");

	$size = getimagesize($file);		/* Propiedades de la imagen */

	if ($width == -1) {
		$height = $size[1];
		$width = $size[0];
	}
	else {
		$porc = $width * 100 / $size[0];		// Calculo el porcentaje en que se reduce la imagen..
		$height = $porc * $size[1] / 100;		// Calculo el alto de la nueva imagen..
	}

	if ($maxWidth != -1)		// Si la imagen tiene que tener un ancho máximo..
		if ($width > $maxWidth) {		// Si el ancho es mayor al ancho máximo..
			$height = $maxWidth * $height / $width;		// Calculo el alto proporcional al ancho máximo..
			$width = $maxWidth;		// Le asigno el ancho máximo..
		}

	if ($maxHeight != -1)		// Si la imagen tiene que tener un alto máximo..
		if ($height > $maxHeight) {		// Si el alto es mayor al ancho máximo..
			$width = $maxHeight * $width / $height;		// Calculo el alto proporcional al ancho máximo..
			$height = $maxHeight;		// Le asigno el ancho máximo..
		}

	$im = imagecreatefromgif($file);		/* Tomo la imagen de origen */
	$img = imagecreatetruecolor($width, $height);		/* [0] Nuevo ancho, [1] ALTO, me creo un CANVAS, algo similar que en Firework */
//	imagecopyresized($img, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);		/* Copio en mi CANVAS la imagen $im en la dimensión que deseo */
	imagecopyresampled($img, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
	imagegif($img);		/* Exporto la CANVAS a GIF */
	imagedestroy($img);		/* La Borro de la Cache */
}
开发者ID:javierlov,项目名称:FuentesWeb,代码行数:33,代码来源:images.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imageinterlace函数代码示例发布时间:2022-05-15
下一篇:
PHP imagegd2函数代码示例发布时间: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