SoFunction
Updated on 2025-03-01

PHP code to upload images and put transparent watermark on the images


$im = imagecreatefromjpeg($_file["upload"]["tmp_name"]); //The picture of the example you want to fetch water
$watermark = imagecreatefrommpng(""); //Path of the watermark image
$im_x = imagesx($im);
$im_y = imagesy($im);
$w_x = imagesx($watermark);
$w_y = imagesy($watermark);
imagecopy($im,$watermark ,$im_x-$w_x,$im_y-$w_y,0,0,$w_x,$w_y);
imagejpeg($im); //You can add a path to save the watermarked image
//You can use type to determine the image type
//switch($_file["upload"]["type"])
//case:1
// Then use different functions
//imagejpeg() corresponds to jpeg
//imagegif() corresponds to gif
//imagepng() corresponds to png
imagedestroy($im);