从Base64字符串中提取图像尺寸 [英] Extract Image Dimensions from Base64 String
本文介绍了从Base64字符串中提取图像尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种检测尺寸的相对简单的方法(可能是正则表达式?) - 高度& width - 来自base64字符串的图像(也许是文件大小)?也就是说没有实际创建图像资源?
Is there a relatively simple way (perhaps regular expressions?) of detecting the dimensions -height & width - of an image from a base64 string (and perhaps the filesize)? That is to say without actually creating an image resource?
推荐答案
解码base64,并使用 getimagesizefromstring( )
。
Decode the base64, and use getimagesizefromstring()
.
http://www.php.net/manual/en/function.getimagesizefromstring.php
这比写自己的方式更可靠处理每种可用的图像类型。
This will be way more reliable than trying to write your own handling of each image type available.
这篇关于从Base64字符串中提取图像尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文