Friday, April 29, 2011

Convert jpg image to gif, png & bmp format using PHP

Hi all,

How can I convert a single jpg image into 3 different image format gif , png and bmp using PHP?

Pls help

From stackoverflow
  • Use libGD — http://www.php.net/manual/en/book.image.php

    riad : But its a huge library file, Could u pls help me for a perticular one? which code i have to use?
  • You first create an image object out of your file with imagecreatefromjpeg(). You then dump that object into different formats (using imagegif() for example):

    $imageObject = imagecreatefromjpeg($imageFile);
    imagegif($imageObject, $imageFile . '.gif');
    imagepng($imageObject, $imageFile . '.png');
    imagewbmp($imageObject, $imageFile . '.bmp');
    
    riad : thanks bro.its working properly.
    Evert : Note that WBMP is not the BMP as you might know it: http://en.wikipedia.org/wiki/Wbmp
    Jeff Winkworth : great answer, exactly what i was lookking for too

0 comments:

Post a Comment