Hello. There is a function of overlaying a watermark on the uploaded photo:
function watermark($file, $watermark) { if (empty($file) || empty($watermark)) { return false; } $wh = getimagesize($watermark); $fh = getimagesize($file); $rwatermark = imagecreatefrompng($watermark); $rfile = imagecreatefromjpeg($file); imagecopy($rfile, $rwatermark, $fh[0] - $wh[0], $fh[1] - $wh[1], 0, 0, $wh[1], $wh[1]); imagejpeg($rfile, $file, '80'); imagedestroy($rwatermark); imagedestroy($rfile); return true; } Photo upload code:
foreach ($_FILES['file']['name'] as $k => $f) { if (!$_FILES['file']['error'][$k]) { if (is_uploaded_file($_FILES['file']['tmp_name'][$k])) { $newfile = "$imgDir/" . $_FILES['file']['name'][$k]; if (move_uploaded_file($_FILES['file']['tmp_name'][$k], $newfile)) { watermark($newfile, './water.png'); $fsave = $_FILES['file']['name'][$k]; header("Location: /index.php"); } } } } So, the watermark now falls in the lower right corner. How to make a watermark overlay in the center of the uploaded photo? The size of the uploaded photo is fixed - 240x320.
I would be grateful for any useful information.