Created
December 22, 2019 05:03
-
-
Save gvgvgvijayan/f15dd5e623a86b9ff9fd63598a33141d to your computer and use it in GitHub Desktop.
This is used to create basic filled rectangle image using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$handle = imagecreatetruecolor(640, 480); #create a 640px wide 480px height image. Consider this like canvas to draw. | |
$green = imagecolorallocate($handle, 0, 255, 0); #assign green color | |
imagefilledrectangle($handle, 0, 0, 640, 480, $green); #Create filled rectangle with green color. Consider like this the shape drawn over the canvas. | |
# Jpeg conversion | |
header("Content-type: image/jpg"); | |
imagejpeg($handle); | |
imagedestroy($handle); #Destroy the image handle to free up the resource |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment