Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Convert Gif & Png To Jpeg


12 replies to this topic

#11 galexcd

    Trap Grand Marshal Member

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,331 posts
  • Gender:Not Telling
  • myCENT:39.82

Posted 30 April 2008 - 03:52 PM

I know this is an old topic but nobody has given the easiest answer yet to this simple question. I believe GD library has some php functions for you to use to do this. Something like this should work:


$url="/images/convert.gif";  //url of image you want to convert (you will have to make an image upload script if you want to get these from user's harddrives)
$from="gif";  //convert from:  gif | png | jpeg
$to="png";  //convert to:  gif | png | jpeg
//------------------------------------------------------
header("Content-Type: image/".$to);
@{"image".$to}({"imagecreatefrom".$from}($url));


#12 AndyKos

    Newbie

  • Kontributors
  • Pip
  • 1 posts

Posted 25 May 2010 - 05:58 PM

View PostRojay, on 08 August 2005 - 07:07 AM, said:

how can i convert gifs and pngs to jpeg using php ??

If you ended up here from google searching for this like I did, this may help:

useful php info

#13 Guest_rob1951_*

  • Guests

Posted 07 June 2011 - 10:25 PM

To convert png to jpg try this:

Get a file from a form input
do some stuff to separate off the extension then...

if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
imagejpeg($src, 'test.jpg');
}

similar if the input image is gif
or to convert e.g. jpg to gif use imagegif instead of imagejpeg




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users