PHP 使用PHP和GD库进行图像处理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 使用PHP和GD库进行图像处理相关的知识,希望对你有一定的参考价值。

//to black and white
if(!file_exists('dw-bw.png')) {
	$img = imagecreatefrompng('dw-manipulate-me.png');
	imagefilter($img,IMG_FILTER_GRAYSCALE);
	imagepng($img,'db-bw.png');
	imagedestroy($img);
}

//to negative
if(!file_exists('dw-negative.png')) {
	$img = imagecreatefrompng('dw-manipulate-me.png');
	imagefilter($img,IMG_FILTER_NEGATE);
	imagepng($img,'db-negative.png');
	imagedestroy($img);
}


//to Sepia
if(!file_exists('dw-sepia.png')) {
	$img = imagecreatefrompng('dw-manipulate-me.png');
	imagefilter($img,IMG_FILTER_GRAYSCALE);
	imagefilter($img,IMG_FILTER_COLORIZE,100,50,0);
	imagepng($img,'db-sepia.png');
	imagedestroy($img);
}

以上是关于PHP 使用PHP和GD库进行图像处理的主要内容,如果未能解决你的问题,请参考以下文章