How to rotate image repetitively in php without increasing its file size

I am currently using imagerotate() available in php GD to let user rotate images. Whenever user rotates like 45 degree, 75 degree etc, background color is added to make image have rectangle shape. The more the number of time user rotates,the bigger the image size and the wider the background color area.

$image = imagerotate($image,45, 0xFFFFFF);

Is there anyway in php gd to rotate image with free degree(eg: 45 degrees,75 degrees, 306 degrees) without adding any background image or without increasing file image?

Edit: I get this error: "Fatal error: Allowed memory size of 33554432 bytes exhausted" when image size is getting bigger and white area is getting wider. That's why I want to know any other way to rotate image.

Thank you.


Try to set the background to black, which would be 0's, and also use JPEG , which is a compressed image format. This MAY help - I have not tested myself though. Try it.

Example:

$image = imagerotate($image, 45, 0x000000);

I was about to write some code here with the same answer of DCoder.

That is the best process you can apply since it only requires one transformation.

Bye

链接地址: http://www.djcxy.com/p/61144.html

上一篇: 无损图像旋转PHP

下一篇: 如何在不增加文件大小的情况下在PHP中重复旋转图像