Created
May 18, 2013 21:00
-
-
Save ma4a/5605779 to your computer and use it in GitHub Desktop.
Merge 2 PNG-Files without losing alpha channel transparency information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function mergePNGs($dst_fileURL, $temp_fileURL) | |
| { | |
| $resolutionX = 1000; | |
| $resolutionY = 1000; | |
| $dst_im = imagecreatefrompng($dst_fileURL) or die('Error reading image file'); | |
| $src_im = imagecreatefrompng($temp_fileURL) or die('Error reading image file'); | |
| imagealphablending($dst_im, true); | |
| imagesavealpha($dst_im, true); | |
| imagealphablending($src_im, true); | |
| imagesavealpha($src_im, true); | |
| imagecopy($dst_im, $src_im, 0, 0, 0, 0, $resolutionX, $resolutionY); | |
| header("Content-Type: image/png"); | |
| imagePNG($dst_im, $dst_fileURL, 2); | |
| imagedestroy($dst_im); | |
| imagedestroy($src_im); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment