In my web app users are allowed to upload images as their photos. How can I convert different image extensions to JPG? Input files are JPG, PNG or GIF.
Asked
Active
Viewed 9,068 times
2
-
possible duplicate of [Convert jpg image to gif, png & bmp format using PHP](http://stackoverflow.com/questions/755781/convert-jpg-image-to-gif-png-bmp-format-using-php) – Pekka Oct 06 '10 at 13:07
3 Answers
2
Personally, I prefer Image Magick over GD. It's a lot better if you're dealing with large images too; you can run into memory allocation issues with GD.
BBonifield
- 4,903
- 17
- 36
1
With php, you can convert any image to an other using imagepng, imagejpeg, imagegif :
imagepng(imagecreatefromstring(file_get_contents($input)), 'output.png');
In this example, it will save the uploaded image in png with the path 'output.png'
ElGato
- 491
- 1
- 5
- 11