-4

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

I am using the file_get_contents method to obtain a JPEG image file from a url. How do I convert it to a PNG file?

Community
  • 1
  • 1
chinhdung
  • 1
  • 1

1 Answers1

0

I'm going to assume you mean convert.

You can use the GD Library, more specifically the imagepng() function

http://php.net/manual/en/function.imagepng.php

<?php
$im = imagecreatefromjpeg($imageFileURL);
header('Content-Type: image/png');
imagepng($im);

This page will output the image in .png format.

If you are massing this with loops, you can save the files with

<?php
$im = imagecreatefromjpeg($imageFileURL);
imagepng($im, 'filename.png');
nine7ySix
  • 486
  • 2
  • 13