Get image size from handler

◇◆丶佛笑我妖孽 提交于 2019-11-30 05:42:37

问题


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??


回答1:


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.




回答2:


I doubt you can since php gd image object is a generic object, without considerations on the compression that will be used for storage (png/jpg/bmp ...)



来源:https://stackoverflow.com/questions/5514125/get-image-size-from-handler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!