0

The following is the code I'm using in order to convert the GIF file into a PNG file and save it into a variable:

        $art = $_FILES["art"]["name"];
        $art_ext = pathinfo($art, PATHINFO_EXTENSION);
        if(strtoupper($art_ext)=="GIF"){
            $art =  imagepng(imagecreatefromstring(file_get_contents($_FILES["art"]["tmp_name"])), $art."png");    
        }
        if($art!=""){

        move_uploaded_file($art, "images/".$art );
    }

Also, is there a method for converting an animated gif to a static gif?

pedrum golriz
  • 513
  • 8
  • 27
  • 1
    Please clarify what your actual question is. The title is not relevant to the question you ask in the body unless you are posting this as a wiki. – Isaiah Turner Sep 02 '13 at 04:16

2 Answers2

0

This code should work. I assume you are following the example at Convert JPG/GIF image to PNG in PHP? To convert a gif to a static jif you could honestly just rename the png file you created with your current code to jif. All modern web-browsers and applications will treat a static jif and a png the same.

Community
  • 1
  • 1
Isaiah Turner
  • 2,574
  • 1
  • 22
  • 35
0

To get the first frame of an animated gif, you can use imagecreatefromgif and to save as a gif, you use imagegif, so it would be:

$art =  imagegif(imagecreatefromgif($_FILES["art"]["tmp_name"]), $art."gif");
jeroen
  • 91,079
  • 21
  • 114
  • 132