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 of it
Before :
After :
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With