How to clone a gd resource in PHP
问题 I'm looking for cloning an image in PHP created with imagecreatetruecolor or some other image creation function.. As it was said in the comment, no you can't do a simple affection like : $copy = $original; This because ressources are reference and could not be copied like scalar values. Example : $a = imagecreatetruecolor(10,10); $b = $a; var_dump($a, $b); // resource(2, gd) // resource(2, gd) 回答1: This little function will clone an image resource while retaining the alpha channel