Back to the snippets index

Display image without saving ( Anthony 14/6/2008 )

This code adds some text to an image and displays it in the browser without saving it.

GD code:

<?php
$image = imagecreatefromjpeg( 'image.jpg' );
imagettftext( $image, 9, 0, 161, 72, -1, 'Arial.ttf', 'Some text' );
imagettftext( $image, 9, 0, 161, 105, -1, 'Arial.ttf', 'Some more text' );
header( "Content-Type: image/png" );
imagepng( $image );
imagedestroy( $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