Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:25:41+00:00 2026-05-16T22:25:41+00:00

I need to create a watermark apply it on a picture and save it

  • 0

I need to create a watermark apply it on a picture and save it with a different name . The current script works pretty well but the only problem is that I need to increase the size of the “sample text” and change the background from black to white . I tried different scenarios , changed the opacity but still can’t change the background color.

function watermark($imag_path, $photo_id) {
    // Load the stamp and the photo to apply the watermark to
    $im = imagecreatefromjpeg("$imag_path");
    echo "imag_path is $imag_path and photoid is $photo_id";
    // First we create our stamp image manually from GD
    $stamp = imagecreatetruecolor(490, 20);

    //$im = imagecreatefromjpeg("$photo_id");
    imagestring($stamp, 5, 20, 2, 'sample text', 0xff0000);

    // 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);

    // Merge the stamp onto our photo with an opacity (transparency) of 100%
    imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 100);
    $new_photo_id = $photo_id . "sample.JPG";
    // Save the image to file and free memory
    imagejpeg($im, "tmp/$new_photo_id");
    imagedestroy($im);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:25:41+00:00Added an answer on May 16, 2026 at 10:25 pm

    Why use a stamp at all? I use the following code on one of my sites:

      $im = imagecreatefromjpeg($path);
    
      function shadow_text($im, $size, $x, $y, $font, $text)
      {
        $black = imagecolorallocate($im, 0, 0, 0);
        $white = imagecolorallocate($im, 255, 255, 255);
        imagettftext($im, $size, 0, $x + 1, $y + 1, $black, $font, $text);
        imagettftext($im, $size, 0, $x + 0, $y + 1, $black, $font, $text);
        imagettftext($im, $size, 0, $x + 0, $y + 0, $white, $font, $text);
      }
    
      $font = '../fonts/verdana.ttf';
      $size = 11;
    
      # calculate maximum height of a character 
      $bbox = imagettfbbox($size, 0, $font, 'ky');
      $x = 8; $y = 8 - $bbox[5];
    
      $text = 'text to be added';
      shadow_text($im, $size, $x, $y, $font, $text);
    
      header("Content-Type: image/jpeg");
      imagejpeg($im, null, 90);
    

    This code runs fast enough that we use it to add dynamic labels on the fly to photos from our photo section as they’re downloaded, rather than save them to disk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using an image watermark code that works great but I also need
I need create clone repository. but I do not know where can I get
Need to create a custom DNS name server using C which will check against
I need to create a block of unique lines to test a different project
I need to create a script where someone will post an opening for a
Well, i have the following need: create 3 dropdownlist with dependencies. My table in
I need create custom tabbar with super class UITabBarController. But i don,t know how
I want add new user from another script and I need create password for
I need to create a script that will log into an authenticated page and
How can I create a watermark over an image using Java? I need user-entered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.