<?php // upload directory
define('UPLOAD_DIR', 'uploads/');
// watermark stamp
$stamp = imagecreatefrompng('../../images/site/stamp.png');
// grab the image
$img = $_POST['image'];
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
// give the file a new name
$file = UPLOAD_DIR . MD5(microtime()) . '.jpg';
// save the file
$success = file_put_contents($file, $data);
//print $success ? $file : 'Unable to save the file.';
// reload to add the watermark
$preWMImage = imagecreatefromjpeg($file);
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// add the watermark
imagecopy(
$preWMImage,
$stamp,
(imagesx($preWMImage) - $sx - $marge_right),
(imagesy($preWMImage) - $sy - $marge_bottom),
0,
0,
imagesx($stamp),
imagesy($stamp)
);
// resave
imagejpeg($preWMImage, $file); ?>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.