English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Examples of PHP imagesx() and imagesy() Functions to Get Image Width and Height

PHP Image Processing

PHP Image Width Function: imagesx()

The imagesx() function is used to get the width of the image, in pixels, and the return value is an integer.

Syntax:

int imagesx(resource image)

The parameter image is a resource returned by functions such as imagecreatetruecolor(), imagecreatefromjpeg(), etc.

PHP Image Height Function: imagesy()

The imagesy() function is used to get the height of the image, the syntax and usage are the same as imagesx().

Syntax:

int imagesy(resource image)

The parameter image is a resource returned by functions such as imagecreatetruecolor(), imagecreatefromjpeg(), etc.

Online Examples

<?php
$img = imagecreatefrompng("w3codebox-logo.png");
echo "Image Width:", imagesx($img),"<br />";
echo "Image Height:", imagesy($img);
?>

Browser Output:

Image Width:290
Image Height:69

Related Articles

Image Information Function:getimagesize()

PHP Image Processing