PHP Get Image Width and Height
PHP Get Image Width Function: imagesx()
The imagesx() function is used to get the width of an image, in pixels, and returns an integer.
Syntax:
int imagesx( resource image )
The image parameter is an image resource returned by functions such as imagecreatetruecolor(), imagecreatefromjpeg(), etc.
PHP Get Image Height Function: imagesy()
The imagesy() function is used to get the height of an image. Its syntax and usage are the same as imagesx().
Syntax:
int imagesy( resource image )
The image parameter is an image resource returned by functions such as imagecreatetruecolor(), imagecreatefromjpeg(), etc.
Example
<?php
$img = imagecreatefrompng("example-logo.png");
echo "图像宽度:",imagesx( $img ),"<br />";
echo "图像高度:",imagesy( $img );
?>
Browser output:
图像宽度:290 图像高度:69
Related Articles
Functions for getting image information:getimagesize()
Other Extensions
PHP Image Processing