这是原始图片:
这是我正在使用的代码:
<?php
$filename = 'image.jpg';
$degrees = 135;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 1);
// Output
imagejpeg($rotate);
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
?>
这是输出:
在这张照片中,背景是黑色的。我希望在旋转后使其变白。你能帮帮我吗?
答案 0 :(得分:2)
请你可以改变你的代码
$source = imagecreatefromjpeg($filename);
// Rotate
$transColor = imagecolorallocatealpha($source, 255, 255, 255, 127);
$rotate = imagerotate($source, $degrees,$transColor);
并试试这个我希望它能帮你上色,你可以用任何其他颜色代码改变它