[英]How to get x y coordinates of an image in php
How to get xy coordinates of an image in PHP?如何在 PHP 中获取图像的 xy 坐标?
I have an image我有一张图片
$image = images/abc.png;
how to get the coordinates of the image using PHP.如何使用PHP获取图像的坐标。
<?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我希望这能回答您的疑问
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 的工作,而是客户端语言(如 JavaScript)的工作
如果您在谈论图像尺寸, getimagesize()
函数适合您!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.