I am using imagerotate() function to turn the image below to a 30 degree angle.
http://postimage.org/image/b7w6dacel/
The problem is that whenever I rotate the image and save it to a new path, in the new path the image is rotated but it has a black color surrounding it, like below.
http://postimage.org/image/n3n1vtr9p/8501961e/
The original image is 450 * 340 and after rotation, the image becomes 560 * 520. Does anyone know what I am doing wrong. Take a look at my source code below. Thanks.
$filename = "static\\". $sessionid . "-1.jpg";
$file= $sessionid . "-1.jpg";
$ir = imagecreatefromjpeg($filename);
$degrees = 30;
$flip=imagerotate($ir, $degrees, 0);
$rotated=imagejpeg($flip, 'c:\\xampp\\htdocs\\'. $file);
Depending on how much you rotate it, the new image will be larger than the original. You will either have to scale or crop the new image. This code will scale
$oldImageto$newWidthand$newHeigth.Hope this helps.