Hello guys, I am having an urgent problem with an application of mine which deals with images. What the app does is that it combines an image and a border, the URLs of which are listed below: http://static.wowhead.com/images/icon_border_medium.png - The Border http://static.wowhead.com/images/icons/medium/inv_wand_34.jpg - The Image Code (markup): So the app was supposed to take the image, put it in the center and then add a border above it. The dimensions of the image are 36x36 and the dimensions of the border are 44x44. Since the image should be in the center, the border starts at 0,0 and the image starts at 4,4 (44-36 = 8, 8/2 = 4). The output was supposed to be a 44x44 picture with the border above the image. The issue is that when I apply the script, the images loose their transparency, alpha and quality. Also the image is never displayed around the border. I would appreciate if any of you guys could help me out with some code that gets the job done. Thank you, -AT-XE
Try this: $dest = imagecreate(44,44); //create image $border = imagecreatefrompng("icon_border_medium.png"); //load boarder $img = imagecreatefromjpeg("inv_wand_34.jpg"); //load img imagecopy($dest, $border, 0, 0, 0, 0, 44, 44); //copy border to dest imagecopy($dest, $img, 4, 4, 0, 0, 36, 36); //copy img to dest $transColor=imagecolorat($dest,1,1); //find transparent color imagecolortransparent($dest, $transColor); //add transparency header("Content-type: image/png"); //header imagepng($dest, null); //output dest PHP:
This code made things better, thanks, however there is still the issue of lost quality. Compare the attached images. As you can see the image loses quality when attached to the border.
I don't notice much of a difference, but my monitor sucks. try adjusting the quality imagepng($dest, null, 100); //output dest PHP: EDIT: I see what you mean now, how it's darker I'm not sure how to fix it.