Note that the image resource returned from the imagerotate() function is an entirely different image resource from your original one.
<?php
$res = imagecreatetruecolor(100, 200);
$res2 = imagerotate($res, 90, 0);
var_dump($res, $res2);
?>
This will output:
resource(2, gd)
resource(3, gd)