How to convert jpeg/jpg format to png/gif transparent format

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…

Thanks for any help…

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");


hope someone will give me some shed on light on this…

Thanks in advanced

How do you know what colour the background is?

If you were using ImageMagick you coulg guess it by finding the colour of the top left pixel.

That’s one of the major thing actually how can I determine whats is the background color is?..

The other problem you have is if the background colour is in the image as well it will also be converted to transparent. It might be better to just fade the edges into transparency instead.