当前位置:网站首页>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 .
边栏推荐
- The latest Android interview collection, Android video extraction audio
- How does win11 unblock the keyboard? Method of unlocking keyboard in win11
- [JDBC Part 1] overview, get connection, CRUD
- Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
- [interview arrangement] 0211 game engine server
- Main functions of OS, Sys and random Standard Libraries
- Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
- Aspose. Word operation word document (I)
- Attitude estimation (complementary filtering)
- Revit secondary development - get the project file path
猜你喜欢
使用 BlocConsumer 同时构建响应式组件和监听状态
UWA Q & a collection
Build your own website (18)
The function is really powerful!
How pyGame rotates pictures
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
Two methods of calling WCF service by C #
Remember aximp once Use of exe tool
ByteDance Android interview, summary of knowledge points + analysis of interview questions
UWA问答精选
随机推荐
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Ren Qian code compilation error modification
IP网络主动测评系统——X-Vision
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Two methods of calling WCF service by C #
反爬通杀神器
Revit secondary development - shielding warning prompt window
SAR image quality evaluation
使用 CustomPaint 绘制基本图形
. Net automapper use
UWA Q & a collection
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
Revit secondary development - get the thickness / length / height of the beam
Interview question 01.02 Determine whether it is character rearrangement - auxiliary array algorithm
IP network active evaluation system -- x-vision
Form组件常用校验规则-2(持续更新中~)
How to turn on win11 game mode? How to turn on game mode in win11
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
C # Development -- pit encountered in JS intermodulation
Dbsync adds support for mongodb and ES