plugin development – How use imagecopy() with wordpress

Hello I’m trying to copy onto every image that I select from media library another image also selected with media library.

            foreach ($getImagesUrls as $url) {
                $marge_right = 10;
                $marge_bottom = 10;
                $sx = imagesx($getWatermarkUrl);
                $sy = imagesy($getWatermarkUrl);

                imagecopy($url, $getWatermarkUrl, imagesx($url) - $sx - $marge_right, imagesy($url) - $sy - $marge_bottom, 0, 0, imagesx($getWatermarkUrl), imagesy($getWatermarkUrl));
            }

I’m trying to use imagecopy like php.net suggest. But when I run the form WordPress return fatal.
Someone can help me to understand how I can do this?