2 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
/**
* Created by PhpStorm.
* User: shellus
* Date: 2016-12-01
* Time: 23:12
*/
require 'vendor/autoload.php';
// import the Intervention Image Manager Class
use Intervention\Image\ImageManager;
// create an image manager instance with favored driver
$manager = new ImageManager(array('driver' => 'gd'));
$img = $manager->make('1.jpg');
for ($y = 0; $y < $img->height(); $y++)
{
for ($x = 0; $x < $img->width(); $x++)
{
$c = $img -> pickColor($x, $y, 'array');
if(abs($c[0] - 205) < 50 && abs($c[1] - 223) < 50 && abs($c[2] - 211) < 50 ){
$c[0] = $c[1] = $c[2] = 255;
$img -> pixel($c, $x, $y);
}
}
}
$img -> save();

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊
請(qǐng)不要用jpg,因?yàn)閖pg不支持透明所以變白了,用imagecreatetruecolor或是imagecreatefrompng
- 2 回答
- 0 關(guān)注
- 119 瀏覽
添加回答
舉報(bào)