<div style="background-color: rgb(250,250,250); border: 1px solid #000; color: #222; font-family: monospace; font-size: 8pt; line-height: 12px; margin-right: 10px; -moz-border-radius: 2px; overflow: auto; padding: 5px; white-space: pre;"><strong><?php</strong>
<span style="color: #C77;">$image</span> <strong>=</strong> ImageCreate(<span style="color: #AA0;">70</span>,<span style="color: #AA0;">70</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Let's start with a 70 x 70 px image.</span>
<span style="color: #C77;">$white</span> <strong>=</strong> ImageColorAllocate(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">255</span>,<span style="color: #AA0;">255</span>,<span style="color: #AA0;">255</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Argument 1 is an image resource (e.x. $image), 2-4 are R, G, B color values. Returns a color identifier.</span>
ImageFill(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">0</span>,<span style="color: #AA0;">0</span>,<span style="color: #C77;">$white</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Argument 1 is an image resource, 2 and 3 are x and y values of where to fill, and the fourth is color identifier.</span>
<span style="color: #C77;">$black</span> <strong>=</strong> ImageColorAllocate(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">0</span>,<span style="color: #AA0;">0</span>,<span style="color: #AA0;">0</span>)<strong>;</strong>
ImageString(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">2</span>,<span style="color: #AA0;">1</span>,<span style="color: #AA0;">1</span>,<span style="color: #770;">"Hello World!"</span>,<span style="color: #C77;">$black</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Argument 1 is an image resource, Arg. 2 is font-size, 3 and 4 are x and y positions, 5 is a string, 6 is a color.</span>
<span style="color: #C77;">$red</span> <strong>=</strong> ImageColorAllocate(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">255</span>,<span style="color: #AA0;">0</span>,<span style="color: #AA0;">0</span>)<strong>;</strong>
ImageLine(<span style="color: #C77;">$image</span>,<span style="color: #AA0;">0</span>,<span style="color: #AA0;">14</span>,<span style="color: #AA0;">69</span>,<span style="color: #AA0;">14</span>,<span style="color: #C77;">$red</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Argument 1 is an image resource, 2 and 3 are the X and Y positions of point 1, 4 and 5 are the X and Y positions of the end, and the last is a color.</span>
header(<span style="color: #770;">"Content-type: image/png"</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Tell the browser it's a PNG</span>
ImagePng(<span style="color: #C77;">$image</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Outputs the image as a PNG</span>
ImadeDestroy(<span style="color: #C77;">$image</span>)<strong>;</strong>
<span style="color: #999; font-style: italic;"># Free resources</span>
exit<strong>;</strong>
<strong>?></strong>
</div>