How to get image size from a canvas?

拟墨画扇 提交于 2019-12-12 02:53:43

问题


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

回答1:


Try:

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

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



来源:https://stackoverflow.com/questions/20519172/how-to-get-image-size-from-a-canvas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!