3

This is original image:

enter image description here

This is the code I am using:

<?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);
?>

This is output:

enter image description here

In this picture background is black. I want to make it white after rotation. Could you help me?

Asif Iqbal
  • 1,132
  • 1
  • 10
  • 23
  • Use this link, its help http://stackoverflow.com/questions/4478223/how-do-i-fill-white-background-while-resize-image – Mansoor H Jun 26 '15 at 07:08

1 Answers1

2

please you can change your code just like that

$source = imagecreatefromjpeg($filename);
// Rotate
$transColor = imagecolorallocatealpha($source, 255, 255, 255, 127);
$rotate = imagerotate($source, $degrees,$transColor);

and try this i hope it will help you in color you can change it with any another color code

priya786
  • 1,804
  • 12
  • 11