درج Overlay و Watermark بر روی تصاویر:

کد PHP:

header
('Content-type: image/png');
 
## Red :: 0 - 255
## Green :: 0 - 255
## Blue :: 0 - 255
## Alpha :: 0 - 127
 
$data = array(
    
'file_1' => 'image_1.jpg',
    
'file_2' => 'image_2.png',
    
'position_x' => 80,
    
'position_y' => 90,
    
'watermark' => 'MostafaEs'
);
 
$font = array(
    
'family' => 'fonts/agencyb.ttf',
    
'rotate' => 0,
    
'size' => 17,
);
 
// Image Size
list($width_1$height_1) = getimagesize($data['file_1']);
list(
$width_2$height_2) = getimagesize($data['file_2']);
 
// Image Create
$image_1 imagecreatefromjpeg($data['file_1']);
$image_2 imagecreatefrompng($data['file_2']);
 
// Frame Create
$photoFrame_1 imagecreatetruecolor($width_1$height_1);
$photoFrame_2 imagecreatetruecolor($width_2$height_2);
 
// Frame (1)
imagecopyresampled($photoFrame_1$image_10000$width_1$height_1imagesx($image_1), imagesy($image_1));
 
// Frame (2)
$transparent imagecolorallocatealpha($photoFrame_2000127);
imagefill($photoFrame_200$transparent);
imagecopyresampled($photoFrame_2$image_20000$width_2$height_2imagesx($image_2), imagesy($image_2));
 
// Copy Frame
imagecopy($photoFrame_1$photoFrame_2$data['position_x'], $data['position_y'], 00imagesx($photoFrame_2), imagesy($photoFrame_2));
 
// Image Watermark
$box imagettfbbox($font['size'], $font['rotate'], $font['family'], $data['watermark']);
 
$colors = array(
    
'black' => imagecolorallocatealpha($photoFrame_10000),
    
'white' => imagecolorallocatealpha($photoFrame_12552552550),
    
'red' => imagecolorallocatealpha($photoFrame_12550075),
    
'green' => imagecolorallocatealpha($photoFrame_10255075),
    
'blue' => imagecolorallocatealpha($photoFrame_10025575),
     
    
'custom-1' => imagecolorallocatealpha($photoFrame_12091631045)
);
 
$width imagesx($photoFrame_1);
$height imagesy($photoFrame_1);
 
$margin_top $height-35;
$margin_right $height-3;
$margin_left $width-3;
$margin_bottom 3;
 
imagefilledrectangle($photoFrame_1$margin_left$margin_right$margin_bottom$margin_top$colors['custom-1']);
imagettftext($photoFrame_1$font['size'], $font['rotate'], ($width-$box[4])/2, ($height-10), $colors['black'],  $font['family'], $data['watermark']);
 
imagepng($photoFrame_1);
 
imagedestroy($image_1);
imagedestroy($image_2);
imagedestroy($photoFrame_1);
imagedestroy($photoFrame_2); 

آرایه data رو میبایست دستی ویرایش کنید! دراینجا تصویر اول JPG و تصویر دوم PNG هستش که میتونید بنابه نیازتون توابع رو تغییر بدید!
دراصل کار اصلی این کد درج تصویر دوم بصورت Transparent بر روی تصویر اول هست!