Friday 22 July 2016

Text Watermark a Image in PHP

How to watermark a simple text on a image using PHP?
We can watermark a image using this simple in php. PHP text watermark can be used for creating a copyright  on a image for your website.

header('Content-type: image/jpeg'); // Set the Content Type
$imageJPEG = imagecreatefromjpeg('demo_image.jpg'); // Create Image From Existing File
$textColor = imagecolorallocate($imageJPEG, 255, 255, 255); // Color of the text watermark
$fontStyle = 'my_font.TTF'; // Path of the Font File
$textToWrite = "WaterMark Text"; // Watermark text to place on image
imagettftext($imageJPEG, 25, 0, 75, 300, $textColor, $fontStyle, $textToWrite);
imagejpeg($imageJPEG); // Show Image inBrowser
imagedestroy($imageJPEG);

No comments:

Post a Comment