Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pushing image with watermark

Featured Replies

I'm revising existing PHP code and trying to change this:

:D


 to:



an output that adds a textual watermark.



I've got part of it (this function)
$img = imagecreatefromjpeg($img_src);

$white = imagecolorallocate($img, 255, 255, 255);

$imagestring($img, 3, 5, imagesy($img)-20, 'Watermark', $white); 

// header('Content-type: image/jpeg');

imagejpeg($img);




I'm just not sure how to "call" the function (passing the $img_src) to display the image rather than using the HTML img.



If I include 
header('Content-type: image/jpeg');

, as recommended, I get an error saying the header is already called (and it is). If I don't include it, I get the image (as bin-hex "text"), rather than the image!

Source for above code

  • Author

NEVER MIND! I figured it out myself :D

1. Create a file called "v_watermark.php":

<?php  

// Load image

$image = imagecreatefromjpeg( '../'.$_GET['pic_path'] );

 if ($image == false) { echo 'no image'; die(); }



// Add colored text

$white = imagecolorallocate($image, 255, 255, 255);

imagestring($image, 3, 5, imagesy($image)-20, 'Watermark text', $white);



// Display image

header('Content-type: image/jpeg');

// header('Content-Disposition: inline; filename=' . $_GET['src'] );

imagejpeg($image);

// die();



?>




2. Then pass the imagepath to the 'page' (even the name of the image dynamically, if desired):



Of course, you can have different image types and different color types and change everything about the text based on the size of the image. Try this link for more info: Dynamic Watermarking with PHP

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.