简体   繁体   中英

How to get x y coordinates of an image in php

How to get xy coordinates of an image in PHP?

I have an image

$image = images/abc.png;

how to get the coordinates of the image using 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

如果您在谈论图像尺寸, getimagesize()函数适合您!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM