开发者

How to draw a circle in img using php?

开发者 https://www.devze.com 2023-02-02 03:33 出处:网络
How to draw a circle in (100px top and 100px left) of img using php ? Image URL : image.jpg I want to load the img then draw a circle on the orginal content 开发者_JS百科of it

How to draw a circle in (100px top and 100px left) of img using php ?

Image URL : image.jpg

I want to load the img then draw a circle on the orginal content 开发者_JS百科of it

Before :

How to draw a circle in img using php?

After :

How to draw a circle in img using php?


Take a look at imagefilledellipse

// Create a image from file.
$image = imagecreatefromjpeg('imgname.jpg');

// choose a color for the ellipse
$ellipseColor = imagecolorallocate($image, 0, 0, 255);

// draw the blue ellipse
imagefilledellipse($image, 100, 100, 10, 10, $ellipseColor);

// Output the image.
header("Content-type: image/jpeg");
imagejpeg($image);


Start by loading the image, this function will be entirely dependant on what your source image is, but for now I'll guess it's a jpeg:

$img = imagecreatefromjpeg('image.jpg');

Then simply create the circle on the image:

imagefilledellipse($img, 100, 100, 20, 20, 0x0000FF);

I'm not sure how you want to return it, but to output it to the browser, simply use the following:

imagejpeg($img);


$img = imagecreatetruecolor(300,300); // create a 300x300 image
imagefilledellipse($img, 100, 100, 20, 20, 0x0000FF); /// draw a 20x20 circle at 100,100 using pure blue
0

精彩评论

暂无评论...
验证码 换一张
取 消