在PHP中;函数imagerotate()中的背景颜色选项使用什么格式。什么是在PHP中使用imagerotate()的颜色格式?
$color = "???????";
imagerotate($image, $degrees, $color);
我曾尝试:
$color = "#FFFFFF";
$color = "255255255";
在PHP中;函数imagerotate()中的背景颜色选项使用什么格式。什么是在PHP中使用imagerotate()的颜色格式?
$color = "???????";
imagerotate($image, $degrees, $color);
我曾尝试:
$color = "#FFFFFF";
$color = "255255255";
我认为你必须与imagecolorallocate()指定它:
// sets some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// hexadecimal way
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
您需要previouslly分配所需$color
与imagecolorallocate()
或imagecolorallocatealpha()
。
Example of USE as it is not given above......
// File and rotation
$filename = 'test.jpg';
$degrees = 355;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
$white = imagecolorallocate($source, 255, 255, 255);
// Rotate
$rotate = imagerotate($source, $degrees,$white,0);
// Output
imagejpeg($rotate);
,如果你做只有90,180,270度旋转 - 颜色并不重要 - 那么你可以使用:
imagerotate($image, $degrees, 0);
避免代码混乱(可与PHP 5.6.x )