Manolo
Manolo

Reputation: 26370

How to get image size from a canvas?

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

Upvotes: 0

Views: 789

Answers (1)

kguest
kguest

Reputation: 3844

Try:

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

Details at https://www.php.net/manual/en/function.imagesx.php and https://www.php.net/manual/en/function.imagesy.php

Upvotes: 1

Related Questions