Back to the snippets index

Change a png to a jpg ( Anthony 14/6/2008 )

Any transparency is lost in this case as jpg does not support transparency.
You can change from different formats by changing the imagecreatefrompng and the imagejpeg functions.

GD code:

// Create a new image in the memory from the file 
$png_image imagecreatefrompng"input.png" );

// Save the image as output.jpg
imagejpeg$png_image"output.jpg" );

// Clear the memory of the temporary image 
imagedestroy$png_image );

Change a png to a jpg
Create some text as an image
Crop an image
Display image without saving
Grayscale image
Resize an image
Rotate an image
Watermark an image