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 th开发者_高级运维e 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 theimagepng
function.You could use imagecreatefromstring with imagesx.
Like:
$im = imagecreatefromstring($image);
if ($im !== false) {
echo imagesx($im);
}
If you have GD installed, you can just use something like $size = getimagesize($filename);
精彩评论