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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:58:58+00:00 2026-06-13T14:58:58+00:00

So I found some code on PHP Doc, and edited it slightly to merge

  • 0

So I found some code on PHP Doc, and edited it slightly to merge two images I have. The image is then saved in a folder on the server. However there is a slight problem and I am unable to figure out why it is happening.

Firstly my code:

 $glassurl = $_GET['GlassImg'];
    $frameurl = $_GET['FrameImg'];
    $filename = (int)date("H:i:s");

    $src = imagecreatefromgif($frameurl);
    $dest = imagecreatefromjpeg($glassurl);

    imagecolortransparent($src, imagecolorat($src, 0, 0));

    imagealphablending($dest, false);
    imagesavealpha($dest, true);
    imagealphablending($src, false);
    imagesavealpha($src, true);

    $src_x = imagesx($src);
    $src_y = imagesy($src);
    imagecopymerge($dest, $src, 0, 0, 0, 0, $src_x, $src_y, 100);

    // Output and free from memory
    imagepng($dest, 'uploads/imagetest.png');
    imagegif($dest);

    imagedestroy($dest);
    imagedestroy($src

);

Secondly some information about the images:

  1. Both Images are exactly the same size
  2. The ‘pattern’ image is just a block colour/pattern
  3. The frame image has transparent parts within the frame (to allow pattern to show through)
  4. The area around the frame is white to hise the excess pattern

I was hoping that when I overlayed the frame onto the pattern because of these parts that it would produce a window frame, with the glass pattern inside, and the white would hide the remaining patten.

To illustrate I have provided the images. and what happens.

Pattern:

pattern

Frame:

frame

Result:

result

As you can see it doesn’t result in what I expected. Can anyone please tell me where I am going wrong? I want to overlay the frame onto the pattern, keeping the transparent center and using the excess white to cover the rest of the patter. Any help is greatly appreciated.

  • 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-13T14:59:00+00:00Added an answer on June 13, 2026 at 2:59 pm

    Please note that your frame has white edges and if you sill want the windows to be wite you need to crop it and remove the imagecolortransparent added below if not you can use this

    $imgl = "thumb/pattern.png";
    $img2 = "thumb/frame.png";
    
    $dest = imagecreatefrompng($imgl);
    $src = imagecreatefrompng($img2);
    imagecolortransparent($src, imagecolorat($src, 0, 0));
    
    $src_x = imagesx($src);
    $src_y = imagesy($src);
    imagecopymerge($dest, $src, 0, 0, 0, 0, $src_x, $src_y, 100);
    
    // Output and free from memory
    header('Content-Type: image/png');
    imagegif($dest);
    
    imagedestroy($dest);
    imagedestroy($src);
    

    Output

    enter image description here

    You can also have

    $imgl = "thumb/pattern.png";
    $img2 = "thumb/frame.png";
    
    $dest = imagecreatefrompng($imgl);
    $src = imagecreatefrompng($img2);
    
    $src_x = imagesx($src);
    $src_y = imagesy($src);
    
    $srcNew = imagecreatetruecolor($src_x, $src_y);
    ImageColorTransparent($srcNew, imageColorAllocate($srcNew, 0, 0, 0));
    imagecopy($srcNew, $src, 70, 50, 78, 60, 473, 293);
    imagecopymerge($dest, $srcNew, 0, 0, 0, 0, $src_x, $src_y, 100);
    
    header('Content-Type: image/png');
    imagegif($dest);
    
    imagedestroy($dest);
    imagedestroy($src);
    

    Output

    enter image description here

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

Sidebar

Related Questions

I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
I have found some code which recognize circles in particular image and I was
I have been reading some WordPress PHP code on GitHub and I found that
I'm very new to php. I found some CMS like code for east text
I have found some code snippet in the internet. But it is missing some
I found some php code that was an alternative to cron I'm a total
I'm not a PHP guy so I googled and found some simple code for
I have some HTML/PHP code in Dreamweaver and for the life of me I
I was reading some php code source and found the following: $failed |= is_numeric(
Hi all I have found some really good code over on http://apptools.com thats helped

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.