You can use this function in combination with imagecreatefromstring() to clone the gd resource with minimum fuss (no writing to tmp file):<?phpfunction cloneGd($gd){ ob_start(); imagegd2($gd); return imagecreatefromstring(ob_get_clean());}?>