当前位置:网站首页>PHP method of obtaining image information
PHP method of obtaining image information
2022-07-07 20:09:00 【salestina】
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 .
边栏推荐
猜你喜欢
Make this crmeb single merchant wechat mall system popular, so easy to use!
多个线程之间如何协同
编译器优化那些事儿(4):归纳变量
vulnhub之school 1
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
School 1 of vulnhub
Cloud 组件发展升级
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Interpretation of transpose convolution theory (input-output size analysis)
随机推荐
[auto.js] automatic script
Welcome to the markdown editor
使用高斯Redis实现二级索引
模拟实现string类
RESTAPI 版本控制策略【eolink 翻译】
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
CSDN语法说明
openEuler 有奖捉虫活动,来参与一下?
8 CAS
ASP. Net learning & ASP's one word
Sword finger offer II 013 Sum of two-dimensional submatrix
Visual Studio 插件之CodeMaid自动整理代码
The project manager's "eight interview questions" is equal to a meeting
Force buckle 1037 Effective boomerang
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
mysql 的一些重要知识
YoloV6:YoloV6+Win10---训练自己得数据集
pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
如何在软件研发阶段落地安全实践