fifin04 Posted September 27, 2010 Share Posted September 27, 2010 Hi all, I am currently making a website that has e-custom functions and a back end for the client. I want them to be able to upload images - but they need to be transparent. I do not want to leave this in the hands of the client, so I am looking at ways of using the GD library to make the change I got no issue with the png/gif type for upload/resize function since this type already transparent background but my major problems is how to deal with jpeg/jpg image type which is their background was not a transparent...so is it possible I can change/ convert to png/gif type upon successful of uploading image...so the new final image will be png/gif type with transparent background...is it doable...I am not even sure it is possible...? Thanks for any help.. Quote Link to comment https://forums.phpfreaks.com/topic/214535-how-to-convert-jpegjpg-format-to-pnggif-transparent-format/ Share on other sites More sharing options...
fifin04 Posted September 27, 2010 Author Share Posted September 27, 2010 I do try with this tiny script and it's do the trick the only thing is the image is still having background colour so how can I remove the background colour and make it as transparent background here's the code //source jpeg image with white background colour it can be any colour as I assume $image = ImageCreateFromJPEG("bunnyjpeg_nottransparent.jpg"); header("Content-Type: image/png"); ImageJpeg($image, "mynewbunnypic.png"); ImageDestroy($image); hope someone will give me some shed on light on this... Thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/214535-how-to-convert-jpegjpg-format-to-pnggif-transparent-format/#findComment-1116365 Share on other sites More sharing options...
Psycho Posted September 27, 2010 Share Posted September 27, 2010 imagecolortransparent(): http://php.net/manual/en/function.imagecolortransparent.php Do you have some logic in mind to determine "which" color should be made transparent? For example, if you decide that white should always be transparent, then that is simple enough. But,the image could have white that is part of the background and white that is part of the image itself. It would be difficult, if not impossible to programatically determine which is which and even if you could it would be difficult to make some portions of the same color transparent while making other portions not transparent. For example, in this image you would want to make the outside white color transparent, but not the white which makes up "Quaker State". You will also have a heck of a time dealing with the vignette Quote Link to comment https://forums.phpfreaks.com/topic/214535-how-to-convert-jpegjpg-format-to-pnggif-transparent-format/#findComment-1116399 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.