sarmenhb
sarmenhb

Reputation:

trying to understand something about php gd

if i have something like this

<?php
$image = imagecreate(300,20);
$background = imagecolorallocate($image,0,0,0);
$foreground = imagecolorallocate($image,255,255,255);


imagestring($image,5,5,1,'sarmenhb, $foreground);
header('Content-type: image/jpeg');
imagejpeg($image);
?>

how does php know the first imagecolorallocate function will be my background witout even specifying it? what if i have multiple functions of that type listed. how will php associate which one ill be using for the background?

thnx

Upvotes: 0

Views: 69

Answers (1)

Kane Wallmann
Kane Wallmann

Reputation: 2322

According to the official PHP manual:

Note: The first call to imagecolorallocate() fills the background color in palette-based images - images created using imagecreate().

https://www.php.net/manual/en/function.imagecolorallocate.php

Upvotes: 4

Related Questions