Reputation: 7466
I have loaded an image from database to a variable named $image.
How can I get the width of the image while it is stored in the variable?
The $image variable contains the data of the image. When I store the image, I just read it from the temp folder and write it to the database.
The accepted answer fulfills this question.
However, I am doing some resizing on the $im variable, so I need to reconvert it to string data, that can be done with the imagepng
function.
Upvotes: 1
Views: 445
Reputation: 1635
If you have GD installed, you can just use something like $size = getimagesize($filename);
Upvotes: -1
Reputation: 54649
You could use imagecreatefromstring with imagesx.
Like:
$im = imagecreatefromstring($image);
if ($im !== false) {
echo imagesx($im);
}
Upvotes: 2