tags:

views:

38

answers:

1

I have an image I have to rotate that image 25 degree. if I rotate it shows some black background. How can I avoid that. How can I rotate image completely with out showing the black portion by using PHP GD. I cant use js for rotation. because I have to merge the image with another one after rotation. any body have the scripts for this please help me.

A: 

The black area is unavoidable on rotation - PHP (and GD for that matter) isn't Photoshop's content-aware-fill and won't generate more picture for you during the rotation to cover up the black bits.

You've got two choices:

  1. do some math and figure out what size of rectangle you can slice out of the rotated image to eliminate the black borders (eg: the post-rotation image will be smaller than the original)

  2. blow up the original image prior to rotating, such that after rotating, you can slice out a rectangular chunk that matches the original non-rotated size. Again, calls for a bit of math.

Of course, this all depends on just how you're rotating the image. Rotating on a corner will lead to vastly different results than rotating on the center of the image.

Marc B
Hi sir but one of the parameter of imagerotate () function is for transperancy. In php.net manuel they says if we set it as zero it will show transperancy. but its not working why?
learner
Hello Marc can I change the co ordinates of the image using php?
learner
Transparency is useless unless you save the image in a format that supports it, such as PNG. JPGs do not support it, period. And what do you mean, change the coordinates? Move the image content around? You can use imagecopy() to 'move' things around.
Marc B