当前位置:网站首页>php 获取图片信息的方法
php 获取图片信息的方法
2022-07-07 21:43:00 【游戏编程】
想通过php获取图片的宽高,下面是两种方法,可以作为参考。
方法一:
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)');$thumb_url="https://dss0.bdstatic.com/-0U0bXSm1A5BphGlnYG/tam-ogel/2dbeac414fc1ee690d00c764c89a187e_121_121.png";$imageInfo=getimagesize($thumb_url);print_r($imageInfo);打印结果为:

方法二:
$refer="https://dss0.bdstatic.com";$option=array('http'=>array('header'=>"Referer: {$refer}"));$context=stream_context_create($option);//创建资源流上下文$thumb_url="https://dss0.bdstatic.com/-0U0bXSm1A5BphGlnYG/tam-ogel/2dbeac414fc1ee690d00c764c89a187e_121_121.png";$file_contents = file_get_contents($thumb_url,false, $context);//将整个文件读入一个字符串$thumb_size = getimagesizefromstring($file_contents);//从字符串中获取图像尺寸信息print_r($thumb_size);打印结果为:

两种方法都可以获取图片的信息,可自行选择使用哪一种。
作者:salestina
游戏编程,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
边栏推荐
- Oracle advanced (VI) Oracle expdp/impdp details
- [colmap] sparse reconstruction is converted to mvsnet format input
- Can I open a stock account directly online now? Is it safe?
- Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
- Revit secondary development - Hide occlusion elements
- Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
- Revit secondary development - project file to family file
- Crawler (17) - Interview (2) | crawler interview question bank
- Cv2.resize function reports an error: error: (-215:assertion failed) func= 0 in function ‘cv::hal::resize‘
- Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
猜你喜欢

Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold

Time standard library

Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
Talk about relational database and serverless
![[advanced MySQL] index details (I): index data page structure](/img/e7/fe4591a721a71c3c38d6e4448af6af.png)
[advanced MySQL] index details (I): index data page structure

NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?

The whole network "chases" Zhong Xuegao

三元表达式、各生成式、匿名函数

Node:504 error reporting

如何选择合适的自动化测试工具?
随机推荐
Anti climbing killer
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
The strongest installation of the twin tower model, Google is playing "antique" again?
Firefox browser installation impression notes clipping
Record layoutrebuild Forcerebuildlayoutimmediate does not take effect
Revit secondary development - get the thickness / length / height of the beam
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
MIT6.S081-Lab9 FS [2021Fall]
ByteDance senior engineer interview, easy to get started, fluent
How to choose the appropriate automated testing tools?
OpenGL configuration vs2019
Revit secondary development - project file to family file
Dbsync adds support for mongodb and ES
How does win11 time display the day of the week? How does win11 display the day of the week today?
强化学习-学习笔记9 | Multi-Step-TD-Target
SAR影像质量评估
TCP/IP 协议栈
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
DNS series (I): why does the updated DNS record not take effect?
OpenGL job - texture