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

  • Home
  • SEARCH
  • 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 7974087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:16:25+00:00 2026-06-04T08:16:25+00:00

I had the below code that load image from DB. There are more than

  • 0

I had the below code that load image from DB. There are more than 600 rows of image has been inserted into the DB. I need the script that can perform these action:

Step 1) Load the image from DB
Step 2) process the image by putting the watermark
Step 3) Output the image to the browser.

I had the below code, that load and show the image. but I don’t have any idea how to do the watermark.

$dbconn = @mysql_connect($mysql_server,$mysql_manager_id,$mysql_manager_pw) or exit("SERVER Unavailable"); 
@mysql_select_db($mysql_database,$dbconn) or exit("DB Unavailable"); 

$sql = "SELECT type,content FROM upload WHERE id=". $_GET["imgid"]; 

$result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!"); 

$contenttype = @mysql_result($result,0,"type"); 
$image = @mysql_result($result,0,"content"); 


header("Content-type: $contenttype"); 
echo $image;

mysql_close($dbconn); 

?>

Please help…

  • 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-06-04T08:16:26+00:00Added an answer on June 4, 2026 at 8:16 am

    Finally I get the solution, here is the code:

    <?php
    
    $dbconn = @mysql_connect($mysql_server,$mysql_manager_id,$mysql_manager_pw) or exit("SERVER Unavailable"); 
    @mysql_select_db($mysql_database,$dbconn) or exit("DB Unavailable"); 
    
    $sql = "SELECT id, original_name, type, content FROM upload WHERE id=". $_GET["imgid"]; 
    
    $result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!"); 
    
    $fileID = @mysql_result($result,0,"id");
    $contenttype = @mysql_result($result,0,"type"); 
    $filename = @mysql_result($result,0,"original_name");
    $image = @mysql_result($result,0,"content"); 
    
    
    $fileXtension = pathinfo($filename, PATHINFO_EXTENSION);
    $finalFileName = $fileID.".".$fileXtension;
    
    // put the file on temporary folder
    $filePutPath = "/your/temporary/folder/".$finalFileName;
    
    // put the contents onto file system
    file_put_contents($filePutPath, $image);
    
    
    // get the watermark image
    $stamp = imagecreatefrompng('../images/watermark.png');
    
    switch($fileXtension)
    {
      case 'JPEG':
      case 'JPG' :
      case 'jpg' :
      case 'jpeg':
        $im = imagecreatefromjpeg($filePutPath);
      break;
    
      case 'gif' :
      case 'GIF' :
        $im = imagecreatefromgif($filePutPath);
      break;
    
      case 'png' :
      case 'PNG' :
        $im = imagecreatefromgif($filePutPath);
      break;
    
      default :
      break;
    }
    
    list($width, $height) = getimagesize($filePutPath);
    
    // set area for the watermark to be repeated
    imagecreatetruecolor($width, $height);
    
    // Set the tile (Combine the source image and the watermark image together)
    imagesettile($im, $stamp);
    
    // Make the watermark repeat the area
    imagefilledrectangle($im, 0, 0, $width, $height, IMG_COLOR_TILED);
    
    
    header("Content-type: $contenttype"); 
    
    // free the memory
    imagejpeg($im);
    imagedestroy($im);
    
    // delete the file on temporary folder
    unlink($filePutPath);
    
    mysql_close($dbconn); 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to Remove Badge from the tabbar item i had use below code but
This isn't my code, I'm just troubleshooting it. Some code that has been working
I had used the below code to get the row index of the UIPickerView
I had a weird problem here. Please check the code below. I do not
I had written the code given below: Its output datatype is integers, I want
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
I had 2 classes as below. From my understanding compiler must not complain at
If I had an ASP.NET 4.0 DataView control that looked like below, how can
I am told that the configuration below is possible, but have had significant difficulty
In my code I have a query that looks like this: $load_query = LOAD

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.