Reputation: 786
I have on server the image. I want to make a watermark (text) on image and save this image as a new with other name. My function is:
function watermark($path, $watermark){
$imageURL = $path;
list($width,$height) = getimagesize($imageURL);
$imageProperties = imagecreatetruecolor($width, $height);
$targetLayer = imagecreatefromjpeg($imageURL);
imagecopyresampled($imageProperties, $targetLayer, 0, 0, 0, 0, $width, $height, $width, $height);
$WaterMarkText = $watermark;
$watermarkColor = imagecolorallocate($imageProperties, 191,191,191);
imagestring($imageProperties, 5, 130, 117, $WaterMarkText, $watermarkColor);
imagejpeg ($imageProperties);
imagedestroy($targetLayer);
imagedestroy($imageProperties);
}
where parameters are:
$watermark = $_POST['watermark'];
$path = "/images/$file_name";
When I start the scypt, the image with watermark is creating and displays on screen. My aim is to not display the new image but save in the same folder with name: $file_name_watermark. How can i do this?
Upvotes: 0
Views: 212