search
Homephp教程php手册php-GD库的函数(一)
php-GD库的函数(一)Jun 13, 2016 am 10:58 AM
logphpprintoneandfunctionpicturesizeLibraryof

<?php 
	//getimagesize - 取得图片的大小[即长与宽]
	//print_r(getimagesize("./logo_i.gif"));
	//Array ( [0] => 240 [1] => 124 [2] => 1 [3] => width="240" height="124" [bits] => 8 [channels] => 3 [mime] => image/gif ) 

	//image_type_to_mime_type - 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的图像类型的 MIME 类型
	//$aa = getimagesize("./logo_i.gif");
	//print_r(image_type_to_mime_type ($aa));
	
	//imagearc &mdash; 画椭圆弧
	/*bool imagearc(resource $image ,int $cx ,int $cy ,int $w ,int $h , int $s , int $e , int $color);
	//$image:资源
	//$cx:左边离圆心的位置
	//$cy:上边离圆心的位置
	//$w:圆形的直径左右
	//$h:圆形的直径上下
	//$s:0度顺时针画
	//$e:360
	//$color:圆形的颜色
	// 创建一个 200X200 的图像
	$img = imagecreatetruecolor(200, 200);
	// 分配颜色
	$white = imagecolorallocate($img, 255, 255, 255);
	$black = imagecolorallocate($img, 0, 0, 0);
	// 画一个白色的圆
	imagearc($img, 100, 100, 150, 150, 0, 360, $white);
	// 将图像输出到浏览器
	header("Content-type: image/png");
	imagepng($img);
	// 释放内存
	imagedestroy($img);*/

	//imagechar &mdash; 水平地画一个字符
	/*bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color )
	$image:资源
	$font:字体大小
	$x:文字离左边框的距离
	$y:文字离上边框的距离
	$c:将字符串 c 的第一个字符画在 image 指定的图像中
	$color:文字的颜色
	$im = imagecreate(100,100);
	$string = &#39;php&#39;;
	$bg = imagecolorallocate($im, 255, 255, 255);
	$black = imagecolorallocate($im, 0, 0, 0);
	// prints a black "P" in the top left corner
	imagechar($im, 1, 0, 0, $string, $black);
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);*/

	//imagecharup &mdash; 垂直地画一个字符
	/*bool imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color )
	$image:资源
	$font:字体大小
	$x:文字离左边框的距离
	$y:文字离上边框的距离
	$c:将字符串 c 的第一个字符画在 image 指定的图像中
	$color:文字的颜色
	$im = imagecreate(100,100);
	$string = &#39;Note that the first letter is a N&#39;;
	$bg = imagecolorallocate($im, 255, 255, 255);
	$black = imagecolorallocate($im, 0, 0, 0);
	// prints a black "Z" on a white background
	imagecharup($im, 3, 10, 10, $string, $black);
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);
	*/
	
	//imagecolorallocate &mdash; 为一幅图像分配颜色
	/*int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
	$image:图片资源
	$red,$green,$blue分别是所需要的颜色的红,绿,蓝成分。这些参数是 0 到 255 的整数或者十六进制的 0x00 到 0xFF
	第一次对 imagecolorallocate() 的调用会给基于调色板的图像填充背景色
	$im = imagecreate( 100, 100);
	// 背景设为红色
	$background = imagecolorallocate($im, 255, 0, 0);
	// 设定一些颜色
	$white = imagecolorallocate($im, 255, 255, 255);
	$black = imagecolorallocate($im, 0, 0, 0);
	// 十六进制方式
	$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
	$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);
	*/

	//imagecolorallocatealpha &mdash; 为一幅图像分配颜色 + alpha
	/*int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )
	imagecolorallocatealpha() 的行为和 imagecolorallocate() 相同,但多了一个额外的透明度参数 alpha,其值从 0 到 127。0 表示完全不透明,127 表示完全透明。
	$size = 300;
	$image=imagecreatetruecolor($size, $size);
	// 用白色背景加黑色边框画个方框
	$back = imagecolorallocate($image, 255, 255, 255);
	$border = imagecolorallocate($image, 0, 0, 0);
	imagefilledrectangle($image, 0, 0, $size - 1, $size - 1, $back);
	imagerectangle($image, 0, 0, $size - 1, $size - 1, $border);
	$yellow_x = 100;
	$yellow_y = 75;
	$red_x    = 120;
	$red_y    = 165;
	$blue_x   = 187;
	$blue_y   = 125;
	$radius   = 150;
	// 用 alpha 值分配一些颜色
	$yellow = imagecolorallocatealpha($image, 255, 255, 0, 75);
	$red    = imagecolorallocatealpha($image, 255, 0, 0, 75);
	$blue   = imagecolorallocatealpha($image, 0, 0, 255, 75);
	// 画三个交迭的圆
	imagefilledellipse($image, $yellow_x, $yellow_y, $radius, $radius, $yellow);
	imagefilledellipse($image, $red_x, $red_y, $radius, $radius, $red);
	imagefilledellipse($image, $blue_x, $blue_y, $radius, $radius, $blue);
	// 不要忘记输出正确的 header!
	header(&#39;Content-type: image/png&#39;);
	// 最后输出结果
	imagepng($image);
	imagedestroy($image);
	*/

	//imagecolordeallocate &mdash; 取消图像颜色的分配
	/*bool imagecolordeallocate ( resource $image , int $color )
	imagecolordeallocate() 函数取消先前由 imagecolorallocate() 或 imagecolorallocatealpha() 分配的颜色。 
	$im = imagecreate( 100, 100);
	// 背景设为红色
	$background = imagecolorallocate($im, 255, 0, 0);
	// 设定一些颜色
	$white = imagecolorallocate($im, 255, 255, 255);
	imagecolordeallocate($im,$white);
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);*/
	
	//imagecolorexact &mdash; 取得指定颜色的索引值
	/*int imagecolorexact ( resource $image , int $red , int $green , int $blue )
	返回图像调色板中指定颜色的索引值。 
	如果颜色不在图像的调色板中,返回 -1。 
	如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。
	$im = imagecreate( 100, 100);
	// 背景设为红色
	$background = imagecolorallocate($im, 255, 0, 0);
	// 设定一些颜色
	$white = imagecolorallocate($im, 255, 255, 255);
	$aa = imagecolorexact ($im, 255, 0, 0);
	echo $aa;	//不存在返回-1*/

	//imagecolorset &mdash; 给指定调色板索引设定颜色
	/*void imagecolorset ( resource $image , int $index , int $red , int $green , int $blue )
	本函数将调色板中指定的索引设定为指定的颜色。
	$im = imagecreate( 100, 100);
	$background = imagecolorallocate($im, 255, 0, 0);
	for($c = 0;$c<50;$c++){
		imagecolorset($im,$c,255,255,255 );
	}
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);*/
	
	//imagecolortransparent &mdash; 将某个颜色定义为透明色
	/*int imagecolortransparent ( resource $image [, int $color ] )
	imagecolortransparent() 将 image 图像中的透明色设定为 color。image 是 imagecreatetruecolor() 返回的图像标识符,color 是 imagecolorallocate() 返回的颜色标识符。 
	$im = imagecreate(100,100);
	$background = imagecolorallocate($im, 0, 0, 0);
	imagecolortransparent ($im,$background);
	header(&#39;Content-type: image/png&#39;);
	imagepng($im);*/

?>

 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何在技嘉主板上设置键盘启动功能 (技嘉主板启用键盘开机方式)如何在技嘉主板上设置键盘启动功能 (技嘉主板启用键盘开机方式)Dec 31, 2023 pm 05:15 PM

技嘉的主板怎么设置键盘开机首先,要支持键盘开机,一定是PS2键盘!!设置步骤如下:第一步:开机按Del或者F2进入bios,到bios的Advanced(高级)模式普通主板默认进入主板的EZ(简易)模式,需要按F7切换到高级模式,ROG系列主板默认进入bios的高级模式(我们用简体中文来示范)第二步:选择到——【高级】——【高级电源管理(APM)】第三步:找到选项【由PS2键盘唤醒】第四步:这个选项默认是Disabled(关闭)的,下拉之后可以看到三种不同的设置选择,分别是按【空格键】开机、按组

CS玩家的首选:推荐的电脑配置CS玩家的首选:推荐的电脑配置Jan 02, 2024 pm 04:26 PM

1.处理器在选择电脑配置时,处理器是至关重要的组件之一。对于玩CS这样的游戏来说,处理器的性能直接影响游戏的流畅度和反应速度。推荐选择IntelCorei5或i7系列的处理器,因为它们具有强大的多核处理能力和高频率,可以轻松应对CS的高要求。2.显卡显卡是游戏性能的重要因素之一。对于射击游戏如CS而言,显卡的性能直接影响游戏画面的清晰度和流畅度。建议选择NVIDIAGeForceGTX系列或AMDRadeonRX系列的显卡,它们具备出色的图形处理能力和高帧率输出,能够提供更好的游戏体验3.内存电

广联达软件电脑配置推荐;广联达软件对电脑的配置要求广联达软件电脑配置推荐;广联达软件对电脑的配置要求Jan 01, 2024 pm 12:52 PM

广联达软件是一家专注于建筑信息化领域的软件公司,其产品被广泛应用于建筑设计、施工、运营等各个环节。由于广联达软件功能复杂、数据量大,对电脑的配置要求较高。本文将从多个方面详细阐述广联达软件的电脑配置推荐,以帮助读者选择适合的电脑配置处理器广联达软件在进行建筑设计、模拟等操作时,需要进行大量的数据计算和处理,因此对处理器的要求较高。推荐选择多核心、高主频的处理器,如英特尔i7系列或AMDRyzen系列。这些处理器具有较强的计算能力和多线程处理能力,能够更好地满足广联达软件的需求。内存内存是影响计算

主板上的数字音频输出接口-SPDIF OUT主板上的数字音频输出接口-SPDIF OUTJan 14, 2024 pm 04:42 PM

主板上SPDIFOUT连接线序最近我遇到了一个问题,就是关于电线的接线顺序。我上网查了一下,有些资料说1、2、4对应的是out、+5V、接地;而另一些资料则说1、2、4对应的是out、接地、+5V。最好的办法是查看你的主板说明书,如果找不到说明书,你可以使用万用表进行测量。首先找到接地,然后就可以确定其他的接线顺序了。主板vdg怎么接线连接主板的VDG接线时,您需要将VGA连接线的一端插入显示器的VGA接口,另一端插入电脑的显卡VGA接口。请注意,不要将其插入主板的VGA接口。完成连接后,您可以

五大热门Go语言库汇总:开发必备利器五大热门Go语言库汇总:开发必备利器Feb 22, 2024 pm 02:33 PM

五大热门Go语言库汇总:开发必备利器,需要具体代码示例Go语言自从诞生以来,受到了广泛的关注和应用。作为一门新兴的高效、简洁的编程语言,Go的快速发展离不开丰富的开源库的支持。本文将介绍五大热门的Go语言库,这些库在Go开发中扮演了至关重要的角色,为开发者提供了强大的功能和便捷的开发体验。同时,为了更好地理解这些库的用途和功能,我们会结合具体的代码示例进行讲

学习Python,常用的这22个库怎能不掌握?学习Python,常用的这22个库怎能不掌握?Apr 12, 2023 am 10:25 AM

如今全球各个行业内 Python 的使用状况怎么样呢?这个问题就是我写这篇文章的初衷。我找出了22个最常用的 Python 包,希望能给你一些启发。首先我列出了最近一年内 PyPI 上下载量最高的 Python 包。我们来看看这些包的作用,它们的之间的关系,以及为什么会如此流行。1、Urllib38.93亿次下载Urllib3 是 Python 的 HTTP 客户端,它提供了许多 Python 标准库没有的功能。 线程安全 连接池 客户端 SSL/TLS 验证 使用 multipart 编码进行

PHP8.0中的国际化库PHP8.0中的国际化库May 14, 2023 pm 05:51 PM

PHP8.0中的国际化库:UnicodeCLDR和Intl扩展随着全球化的进程,开发跨语言、跨地域的应用程序变得越来越普遍。国际化是实现这一目标的重要组成部分。在PHP8.0中,引入了UnicodeCLDR和Intl扩展,这两个组件都为开发者提供了更好的国际化支持。UnicodeCLDRUnicodeCLDR(CommonLocaleDat

轻松掌握Pillow库安装方法:指南分享轻松掌握Pillow库安装方法:指南分享Jan 17, 2024 am 08:56 AM

Pillow库是Python中一个非常强大的图像处理库,它基于PythonImagingLibrary(PIL)发展而来,并在其基础上进行了优化和扩展。Pillow库提供了丰富的图像处理功能,可以处理各种类型的图像文件,并进行图像的编辑、合并、滤镜处理等操作。本文将为大家提供一个Pillow库的安装指南,帮助你轻松掌握这个强大的图像处理工具。一、安装P

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!