Easy Tutorial
❮ Func Ftp Nb Fput Func Ftp Fget ❯

PHP Get Image Width and Height

PHP Image Processing

PHP Get Image Width Function: imagesx()

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

Syntax:

int imagesx( resource image )

The image parameter is an image resource returned by functions like imagecreatetruecolor() or imagecreatefromjpeg().

PHP Get Image Height Function: imagesy()

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

Syntax:

int imagesy( resource image )

The image parameter is an image resource returned by functions like imagecreatetruecolor() or imagecreatefromjpeg().

Example

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

Browser Output:

Image Width: 290
Image Height: 69

Related Articles

Get Image Information Function: getimagesize()

PHP Image Processing

❮ Func Ftp Nb Fput Func Ftp Fget ❯