{"flag":true,"single":true,"pageTitle":"GD library |Mix image and text into one like stamp|watermark ||PHP","post":{"id":335,"user_id":"1","slug":"gd-library-mix-image-and-text-into-one-like-stamp-watermark-php-t9jx","title":"GD library |Mix image and text into one like stamp|watermark ||PHP","body":"<pre class=\"language-markup\"><code>&lt;?php\r\n\/\/ Load the stamp and the photo to apply the watermark to\r\n$im = imagecreatefromjpeg('uos.jpg');\r\n\r\n\/\/ First we create our stamp image manually from GD\r\n$stamp = imagecreatetruecolor(100, 70); \/\/create new image of 100x70\r\n\r\nimagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF); \/\/create an rectangle image,x1,y1,x2,y2,color\r\nimagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF);\r\nimagestring($stamp, 5, 20, 20, 'Rizi', 0x0000FF);\r\nimagestring($stamp, 3, 20, 40, 'Gondal', 0x0000FF);\r\n\r\n\/\/ Set the margins for the stamp and get the height\/width of the stamp image\r\n$marge_right = 10;\r\n$marge_bottom = 10;\r\n$sx = imagesx($stamp);\r\n$sy = imagesy($stamp);\r\n\r\n\/\/ Merge the stamp onto our photo with an opacity of 50%\r\nimagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50);\r\n\r\n\/\/ Save the image to file and free memory\r\nheader('Content-type: image\/png');\r\nimagepng($im);\r\n\/\/imagepng($im, 'photo_stamp.png'); \/\/save image\r\nimagedestroy($im);\r\n\r\n?&gt;<\/code><\/pre>","category_id":"1","is_private":"0","created_at":"2026-01-07T11:31:26.000000Z","updated_at":"2026-01-07T11:31:26.000000Z","category":{"id":1,"user_id":"1","name":"PHP","slug":"php-3ius","parent_id":null,"created_at":"2023-03-14T03:58:19.000000Z","updated_at":"2023-03-14T03:58:19.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"&lt;?php \/\/ Load the stamp and the photo to apply the watermark to $im = imagecreatefromjpeg('uos.jpg');  \/\/ First we create our stamp image - GD library |Mix image and text into one like stamp|watermark ||PHP (Updated: January 7, 2026) - Read more about GD library |Mix image and text into one like stamp|watermark ||PHP at my programming site [SITE]","categories":[]}