How to Create image in PHP ?
I try to create an image in PHP with imagecreate () function. I wonder if it is possible for a user to download an image as their logo and use that in the image that I create? I know that you can use an existing image to imagecreatefrompng () function, but I also want to add an image to the imagecreate (). but didn't work can anyone help me ?
Thanks
Re: How to Create image in PHP ?
If you are sure that the downloaded file is safe to work with you to determine what type of image it is, then use the "* imagecreatefrom" function for this type of pointing the way to the uploaded file.
Re: How to Create image in PHP ?
Don't use gif unless you have an old version of GD (I doubt it) use png instead. heres a simple example:
<?php
header("Content-type: image/png");
$image = imagecreate( 200, 200 );
imagecolorallocate($image,200,100,100);
imagepng($image);
imagedestroy($image);
?>
Re: How to Create image in PHP ?
Create a 200x200 square (and a bit more)
PHP Code:
<?php
create_image();
print "<img src=image.png?".date("U").">";
function create_image(){
$im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 0); // yellow
imagepng($im,"image.png");
imagedestroy($im);
}
?>