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 8269775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:20:31+00:00 2026-06-08T06:20:31+00:00

My website (coded in html and php in entirety) includes a feature which allows

  • 0

My website (coded in html and php in entirety) includes a feature which allows certain users to upload pictures. The picture is resized and watermarked using this code:

function watermarkpic($filename) {

ini_set('max_input_time', 300);

require 'config.php';  

$watermark = imagecreatefrompng('watermarknew.png');
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);

if(preg_match('/[.](jpg)$/', $filename)) {  
        $originalimage = imagecreatefromjpeg($path_to_image_directory . $filename);  
    } else if (preg_match('/[.](gif)$/', $filename)) {  
        $originalimage = imagecreatefromgif($path_to_image_directory . $filename);  
    } else if (preg_match('/[.](png)$/', $filename)) {  
        $originalimage = imagecreatefrompng($path_to_image_directory . $filename);  
    }  

$originalwidth = imagesx($originalimage);
$originalheight = imagesy($originalimage);

$maxsize = 800;
$imgratio = $originalwidth / $originalheight;

if($imgratio > 1) {
    $finalwidth = $maxsize;
    $finalheight = $maxsize / $imgratio;
}
else {
    $finalheight = $maxsize;
    $finalwidth = $maxsize * $imgratio;
}   

$finalimage = imagecreatetruecolor($finalwidth,$finalheight);

imagecopyresampled($finalimage, $originalimage, 0,0,0,0,$finalwidth,$finalheight,$originalwidth,$originalheight);

imagecopymerge($finalimage, $watermark, 0, 0, 0, 0, $watermarkwidth, $watermarkheight, 100);

//now move the file where it needs to go
if(!file_exists($path_to_medimage_directory)) {  
        if(!mkdir($path_to_medimage_directory)) {  
                die("There was a problem. Please try again!");  
        }  
     } 

 imagejpeg($finalimage, $path_to_medimage_directory . $filename);   
}

The issue is that the watermark has a transparent background, but it shows up as having a black background on the image. I have seen stuff about alpha blending, etc. but I do not really know what this is. I want to understand what I am doing, as well as fix the problem so that the watermark is transparent as it should be. The real picture should fill the space.

Thanks in advance.

  • 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-08T06:20:33+00:00Added an answer on June 8, 2026 at 6:20 am

    So I figured it out; instead of using imagecopymerge() I used imagecopy() and it worked fine.

    I saw somewhere that there may be a bug with imagecopymerge()that causes this in PHP5.

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

Sidebar

Related Questions

I've built a website with a HTML form/ PHP upload for image files, it
I am working on a website where users can edit their page in HTML
I am owning some websites, in php, java and html coded. I want them
I have this html form which calls a php file . The index.html ->
I am trying to write a error reporting feature for a website in php.
I'm writing an API for a website which doesn't have it. Basically, my PHP
i want to get the html Source code of website, it something like: wb.Document...
I'm building a website and having some problem. if the HTML code is like:
I am using the following code to fetch html source website. private string Extract_Source(string
I'm trying to get a HTML source of a website through C# code. When

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.