0

I am trying to rotate an image through GD Library and a database value:

// Image for rotating
 $image = 'images/weather-icons/windDir.png';

 //degrees from database
 $degrees = $row[WindDirDegrees];




 // Create the canvas
 $source = imagecreatefrompng($image) ;

 // Rotate the image
 $rotate = imagerotate($source, $degrees, 0) ;

 // Outputs 
 imagepng($rotate) ;

But all I get as output is a huge amount of "gibbergabber" symbols. Does anyone know why?

braumer
  • 85
  • 11

1 Answers1

0

You are missing header('Content-Type: image/png');

See: http://www.php.net/manual/en/function.imagepng.php

degenerate
  • 1,224
  • 1
  • 14
  • 35
  • I added the header and it gave me an error that the header is already set on line 56 but I have not set any header, I moved it above this line and the error disappeared but it still shows this mass of symbols instead of the image. – braumer Feb 05 '14 at 22:45
  • Try using the exact sample code from the documentation page, and replace `test.png` with your image file `windDir.png` (move this file where the script is located to minimize errors) and if that works, move on from there. – degenerate Feb 05 '14 at 23:03
  • The fact you are getting this error on line 56 when you've pasted at most 15 lines of example code (of which only 5 are actual code) indicates there's probably some context missing that would explain the problems that you've not shared with us. – Jon Marnock Feb 06 '14 at 00:03