Yeah, I was reading the documentation sans user comments. But even the snippet of code I found there didn't work. So I just wrote my own. For anyone who cares (or wants to critique) here it is:
$filename = $GET[target];
$degrees = $GET[angle];
$imagesize = getimagesize($filename);
$x = $imagesize[0];
$y = $imagesize[1];
if($x >= $y)
{
if($degrees == "-90")
{
$src_img = ImageCreateFromJPEG($filename);
$rotated = ImageRotate($src_img,"-90",0);
ImageJPEG($rotated, $filename, 85);
}
else
{
$src_img = ImageCreateFromJPEG($filename);
$preRotate = ImageRotate($src_img,"-90",0);
$rotated = ImageRotate($preRotate,"-180",0);
ImageJPEG($rotated, $filename, 85);
}
}
else
{
if($degrees == "-90")
{
$src_img = ImageCreateFromJPEG($filename);
$a = $y / 2;
$b = $x / 2;
$pos = $a - $b;
$placeholder = imagecreatetruecolor($y, $y);
imagecopy($placeholder, $src_img, $pos, "0", "0", "0", $x, $y);
$rotated = imagerotate($placeholder, "-90", 0);
$newImage = imagecreatetruecolor($y, $x);
imagecopy($newImage, $rotated, 0, 0, 0, $pos, $y, $x);
imagejpeg($newImage, $filename, "90");
}
else
{
$src_img = ImageCreateFromJPEG($filename);
$a = $y / 2;
$b = $x / 2;
$pos = $a - $b;
$placeholder = imagecreatetruecolor($y, $y);
imagecopy($placeholder, $src_img, $pos, "0", "0", "0", $x, $y);
$rotated = imagerotate($placeholder, "90", 0);
$newImage = imagecreatetruecolor($y, $x);
imagecopy($newImage, $rotated, 0, 0, 0, $pos, $y, $x);
imagejpeg($newImage, $filename, "90");
}
}