Jump to content

Create image php

Mr.wut

 

hey... does anyone know how to create image using php... (school work). I tried using imagecreate and imagecreatetruecolor but all i get out is black screen with white square in the middle.... I'm using the example code from the php website and yeah... It ain't working... can anybody help?

This is the code:

"<?php 
header("Content-Type: image/png"); 
// Create the size of image or blank image 
$image = imagecreate(500, 300); 

// Set the background color of image 
$background_color = imagecolorallocate($image, 0, 153, 0); 

// Set the text color of image 
$text_color = imagecolorallocate($image, 255, 255, 255); 

// Function to create image which contains string. 
imagestring($image, 5, 180, 100, "GeeksforGeeks", $text_color); 
imagestring($image, 3, 160, 120, "A computer science portal", $text_color); 



imagepng($image); 
imagedestroy($image); 

?> 
"

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×