I do not have the ability to use PHP's GD imagerotate()
function, so I need to find another solution. I used the rotateImage()
method found in the comments of the imagerotate()
PHP help page, but it is very slow on large images.
I am horrible at image math, and am having a hard time formulating the correct Google search to get me pointed in the correct direction to get my images rotated more quickly.
Ideally I'd like to avoid calling an external application if I can find a solution that is close to the same speed from within PHP.
I do not have ImageMagick installed and would like non-ImageMagick that I can try out before resorting to installing ImageMagick.
Update
I was asked to specify why I had so many restrictions.
I had initially assumed that I could use imagerotate()
directly but I discovered that it only works if PHP is built with PHP's version of GD. Some distros (at least Ubuntu, which I am using as my development environment) refuse to link against PHP's heavily modified version of the GD library. In these cases, trying to call imagerotate()
results in:
PHP Fatal error: Call to undefined function: imagerotate()
I found a PHP workaround for image rotation using GD (without using the imagerotate()
function) but it seems very slow. 15-20 seconds for a 2848x2136 image.
I am hoping to find a faster algorithm using GD but will consider using ImageMagick or some other external library as a last resort. It is not that I am unable to install ImageMagick, it is that I would prefer to find a faster alternative using PHP built-in functions before adding more dependencies to this project.
About exec()
: As a general rule I try pretty hard to avoid handing off to exec()
. In fact, I cannot remember anytime in the last five years that I have had to do this at all. I will consider doing so if nothing else rotates quickly enough, but I'd like to check out some other options before I go there.