<img id='imgt' src='../img/crop00.jpg' alt='img'>
<img id='imgtest' src='../img/crop00.jpg' alt='img'>
js
...
$.ajax({
    url: 'pro20.php',
    type: 'post',
    data: {...},
    success: function(data) {
        $('#imgtest').attr('src', data);
    }
});
php
error_reporting(E_ALL);
ini_set('display_errors', 1);
GD library is turned on - checked with print_r(gd_info()); 
pro20.php
I'm trying to run this code
$stamp = imagecreatefrompng('img/wmark.png');
$im = imagecreatefromjpeg('img/test.jpg');
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
echo imagepng($im);  // my added line 28
Result:
- #imgtest is blank,
- in file system there is nowhere new img created
- error log: 
[:error] [pid 2736:tid 1580] [client ::1:59185] PHP Warning:  imagepng(): supplied resource is not a valid Image resource in ... pro20.php on line 28,
