当前位置:网站首页>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内核浏览器。
边栏推荐
- 23. Merge K ascending linked lists -c language
- Typescript TS basic knowledge type declaration
- PKPM 2020 software installation package download and installation tutorial
- JS number is insufficient, and 0 is added
- [azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
- Anti climbing killer
- 谈谈制造企业如何制定敏捷的数字化转型策略
- Matplotlib drawing interface settings
- Time standard library
- Jerry's power on automatic pairing [chapter]
猜你喜欢
Reptile combat (VII): pictures of the king of reptiles' heroes
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
Jerry's test box configuration channel [chapter]
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
. Net automapper use
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
The latest Android interview collection, Android video extraction audio
How to turn on win11 game mode? How to turn on game mode in win11
海外代理推荐
L2: current situation, prospects and pain points of ZK Rollup
随机推荐
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
Pdf document signature Guide
Record layoutrebuild Forcerebuildlayoutimmediate does not take effect
SAR image quality evaluation
UWA问答精选
三元表达式、各生成式、匿名函数
Blender exchange group, welcome to the water group ~
客户案例|华律网,通过观测云大幅缩短故障定位时间
null == undefined
Revit secondary development - project file to family file
OpenGL configuration vs2019
Matplotlib快速入门
MIT6.S081-Lab9 FS [2021Fall]
How to close eslint related rules
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Crawler (17) - Interview (2) | crawler interview question bank
Jerry's key to initiate pairing [chapter]
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
Win11时间怎么显示星期几?Win11怎么显示今天周几?
Can I open a stock account directly online now? Is it safe?