如何从画布中获取图像大小?

问题描述:

是否可以从画布中获取像素大小?

Is it possible to get the image size in pixels from a canvas?

例如。我知道我可以直接从图像中获得尺寸:

E.g. I know I can achieve it getting the size from the image directly:

list($width, $height) = @getimagesize($_FILES['inputFieldName']['tmp_name'])

但我希望从帆布。例如:

but I want to get it from a canvas. E.g.:

$canvas = imagecreatefromjpeg($image_path);
//Get image size from $canvas


尝试:

$canvas = imagecreatefromjpeg($image_path);
$width = imagesx($canvas);
$height = imagesy($canvas);

http://es1.php.net/manual/en/function.imagesx.php http://es1.php.net/manual/en/function.imagesy.php