当前位置:网站首页>PHP method of obtaining image information
PHP method of obtaining image information
2022-07-07 22:30:00 【Game programming】
Want to pass php Gets the width and height of the image , Here are two ways , As a reference .
Method 1 :
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);The result is :

Method 2 :
$refer="https://dss0.bdstatic.com";$option=array('http'=>array('header'=>"Referer: {$refer}"));$context=stream_context_create($option);// Create a resource flow context $thumb_url="https://dss0.bdstatic.com/-0U0bXSm1A5BphGlnYG/tam-ogel/2dbeac414fc1ee690d00c764c89a187e_121_121.png";$file_contents = file_get_contents($thumb_url,false, $context);// Read the entire file into a string $thumb_size = getimagesizefromstring($file_contents);// Get image size information from string print_r($thumb_size);The result is :

Both methods can obtain the information of pictures , You can choose which one to use .
author :salestina
Game programming , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
边栏推荐
- [open source] Net ORM accessing Firebird database
- Failed to initialize rosdep after installing ROS
- 新版代挂网站PHP源码+去除授权/支持燃鹅代抽
- Variables and constants
- Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
- Get the week start time and week end time of the current date
- 客户案例|华律网,通过观测云大幅缩短故障定位时间
- PKPM 2020软件安装包下载及安装教程
- 使用 CustomPaint 绘制基本图形
- Ren Qian code compilation error modification
猜你喜欢

Tcp/ip protocol stack

Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda

It's worth seeing. Interview sites and interview skills

operator

What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk

UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xf9 in position 56: illegal multibyte sequence

The whole network "chases" Zhong Xuegao

大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?

Build your own website (18)

Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
随机推荐
Aspose. Word operation word document (I)
[interview arrangement] 0211 game engine server
VTOL in Px4_ att_ Control source code analysis [supplement]
Reinforcement learning - learning notes 9 | multi step TD target
Use partial derivatives to display normals in unity
[environment] pycharm sets the tool to convert QRC into py file
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xf9 in position 56: illegal multibyte sequence
Write in front -- Talking about program development
Aspose. Words merge cells
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
Latest Android advanced interview questions summary, Android interview questions and answers
Build your own website (18)
Anti climbing killer
IP网络主动测评系统——X-Vision
Redis官方ORM框架比RedisTemplate更优雅
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Robot autonomous exploration DSVP: code parsing
Implementation method of data platform landing
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Form组件常用校验规则-2(持续更新中~)