Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image size from handler

I'm creating an image editor in JS/PHP, but now I'm having trouble. First of all, I load the image from the database (load a blob with imagecreatefromstring). Then I apply a list of actions to this image. But how can I get the image size from this image handler I have then? Without writing it to a file or use a stream object. How??

like image 721
www.data-blogger.com Avatar asked Apr 01 '11 13:04

www.data-blogger.com


People also ask

How to get size of image in php?

The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image.

How do I find the dimensions of a photo?

You can also right-click on an image & choose properties from the drop-down menu. A new window will appear with several tabs. You'll click the details tab, and there you'll find you image size and dimensions.


1 Answers

In case you mean the image dimensions:

$width  = imagesx($imgHandle);
$height = imagesy($imgHandle);

See imagesx() and imagesy().

If you mean filesize, that's not possible without converting the GD resource to some image format (GIF, PNG, JPEG) because the format determines the image size in bytes.

like image 118
Stefan Gehrig Avatar answered Oct 20 '22 23:10

Stefan Gehrig