![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
imagecreate() function in PHP
The imagecreate() function is used to create a new image. It is preferred to use imagecreatetruecolor() to create an image instead of imagecreate(). This is because the image processing occurs on the highest quality image possible which can be created using imagecreatetruecolor().
Syntax
imagecreate( $width, $height )
Parameters
width: The width of image
height: The height of image
Return
The imagecreate() function returns an image resource identifier on success or FALSE on errors.
Example
The following is an example:
<?php $img = imagecreate(500, 300); $bgcolor = imagecolorallocate($img, 150, 200, 180); $fontcolor = imagecolorallocate($img, 120, 60, 200); imagestring($img, 12, 150, 120, "Demo Text1", $fontcolor); imagestring($img, 3, 150, 100, "Demo Text2", $fontcolor); imagestring($img, 9, 150, 80, "Demo Text3", $fontcolor); imagestring($img, 12, 150, 60, "Demo Text4", $fontcolor); header("Content-Type: image/png"); imagepng($img); imagedestroy($img); ?>
Output
The following is the output:
Advertisements