EagerWolf Posted February 14, 2007 Share Posted February 14, 2007 I would like to make new jpg from png-24 and another jpg file. Thre problem is i want to put transparent image over my image but it shows as it wasn't transparent. I've used: imagecopymerge($croped, $merged_img, $x_zamik, $y_zamik,0 ,0, $framed_img_h,$framed_img_w , 100); $croped = my transparent image $merged = my jpg image Other thinks are just to show position... and I've set pic to 100 ... Also I've tried to set pic to 99 and swap images, so $merged_img was on first place... Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/ Share on other sites More sharing options...
hitman6003 Posted February 14, 2007 Share Posted February 14, 2007 I could be wrong, but I think that jpg is incapable of having transparency...use either png or gif. Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-184961 Share on other sites More sharing options...
EagerWolf Posted February 14, 2007 Author Share Posted February 14, 2007 Jpg file is file, that should be placed below... And above comes PNG file ... Output is JPG file... So ... I guess it should work Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-184972 Share on other sites More sharing options...
hitman6003 Posted February 14, 2007 Share Posted February 14, 2007 I could be wrong, but I think that jpg is incapable of having transparency...use either png or gif. If you are outputting an jpg, regardless of what the "bottom" file is, it will not have transparency. Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-184975 Share on other sites More sharing options...
zq29 Posted February 14, 2007 Share Posted February 14, 2007 Can you post up the rest of your script? Have you switched on alpha blending with imagealphablending()? If you are outputting an jpg, regardless of what the "bottom" file is, it will not have transparency. The transparent png would be layered before outputting as a jpeg, as I understood it. Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-184980 Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Author Share Posted February 15, 2007 So if you want to merge two PNG's with transparency and output JPG, transparency will be lost? Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185090 Share on other sites More sharing options...
hitman6003 Posted February 15, 2007 Share Posted February 15, 2007 As adobe puts it on this page...http://www.adobe.com/support/fireworks/optimize/optimize_jpeg/ : The JPEG format does not support transparency. However, you can simulate background transparency in a JPEG by choosing a Matte color that exactly matches the Web page background color on which the JPEG will appear. Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185100 Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Author Share Posted February 15, 2007 Yes Yes ... everything ok ... What I was asking was: You have got ... PNG Photo and PNG frame... Than you merge PNG Photo and PNG frame into one file using imagecopymerge... Images should be merged correctly... And they are outputed correctly as jpeg... Of course jpeg can not be used as transparent image... I've understood if image is outputed as JPG, than PNG files will loose their transparency when you try to merge. But this doesn't sound possible. Or is it? Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185107 Share on other sites More sharing options...
hitman6003 Posted February 15, 2007 Share Posted February 15, 2007 The original PNG files should not lose anything...the jpeg that is output will not have transparency Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185108 Share on other sites More sharing options...
zq29 Posted February 15, 2007 Share Posted February 15, 2007 I can't believe people are not understanding what is required here. Image 1: A photograph Image 2: A frame with a transparent center The OP wants to layer the frame over the photograph, with the photograph showing through, then saving the resulting image as a jpeg. If this is what you are trying to do, and as I have understood it throughout this post, yes, I believe it is possible. As for jpeg not supporting transparency, that is 100% correct, but by the time the image is ready to be output to jpeg, there is no remaining transparency! I'm just getting ready to leave for the office, when I get there, I'll write up a quick demo script - If I remember! Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185244 Share on other sites More sharing options...
zq29 Posted February 15, 2007 Share Posted February 15, 2007 (edited) Here's some code... <?php $photo = imagecreatefrompng("photo.png"); $w = imagesx($photo); $h = imagesy($photo); imagealphablending($photo,true); $frame = imagecreatefrompng("frame.png"); imagecopy($photo,$frame,0,0,0,0,$w,$h); imagejpeg($photo,"output.jpg",100); ?> Here's the inputs and output: [images removed] Edited January 22, 2020 by requinix removed images at author's request Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185281 Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks for your help... Script didn't work with imagecopymerge... I've tried with imagecopy as SemiApocalyptic has wrote and it works just perfectly! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/38536-solved-imagecopymerge-transparent-png/#findComment-185368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.