当前位置:网站首页>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 .
边栏推荐
- 使用 CustomPaint 绘制基本图形
- [azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
- Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
- The latest Android interview collection, Android video extraction audio
- Robot autonomous exploration DSVP: code parsing
- 使用 BlocConsumer 同时构建响应式组件和监听状态
- Tcp/ip protocol stack
- Overseas agent recommendation
- php 记录完整对接腾讯云直播以及im直播群聊 所遇到的坑
- Main functions of OS, Sys and random Standard Libraries
猜你喜欢
Remember aximp once Use of exe tool
How to judge whether the input content is "number"
The whole network "chases" Zhong Xuegao
Robot autonomous exploration series papers environment code
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
It's worth seeing. Interview sites and interview skills
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
Two methods of calling WCF service by C #
PKPM 2020 software installation package download and installation tutorial
Redis官方ORM框架比RedisTemplate更优雅
随机推荐
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
The strongest installation of the twin tower model, Google is playing "antique" again?
Programming mode - table driven programming
23. Merge K ascending linked lists -c language
Relationship between URL and URI
怎样写一个增广矩阵到txt文件中
Aspose. Words merge cells
【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
npm uninstall和rm直接删除的区别
IP network active evaluation system -- x-vision
Remember aximp once Use of exe tool
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Embedded development: how to choose the right RTOS for the project?
It's worth seeing. Interview sites and interview skills
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Dbsync adds support for mongodb and ES
Anti climbing killer
Aspose. Word operation word document (I)
UWA Q & a collection
How to choose the appropriate automated testing tools?