How to get x y coordinates of an image in PHP?
I have an image
$image = images/abc.png;
how 开发者_开发知识库to get the coordinates of the image using PHP.
Assuming you mean width and height you would do:
$img = imagecreatefromjpeg("img.jpg");
$w = imagesx($img);
$h = imagesy($img);
EDIT: if you want to know where an image is on the screen that is not a job for PHP but for a client-side language, like JavaScript
<?Php
$foo_x=$_POST['foo_x'];
$foo_y=$_POST['foo_y'];
echo "X=$foo_x, Y=$foo_y ";
?>
<form action="" method="post">
<input type="image" alt="Finding coordinates of an image" src="images.jpeg"
name="foo" style="cursor:crosshair;" />
</form>
i hope this answers your query
If you're talking about image dimensions, getimagesize()
function is for you!
精彩评论