当前位置:网站首页>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 .
边栏推荐
猜你喜欢

The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared

LeetCode_7_5

干货分享|DevExpress v22.1原版帮助文档下载集合

Openeuler prize catching activities, to participate in?

ASP. Net kindergarten chain management system source code

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

Implement secondary index with Gaussian redis

Cloud component development and upgrading

ASP. Net learning & ASP's one word

Detailed explanation of Flink parallelism and slot
随机推荐
R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
Visual Studio 插件之CodeMaid自动整理代码
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
MSE API学习
Flink并行度和Slot详解
pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
开源OA开发平台:合同管理使用手册
JVM 类加载机制
Vulnhub's funfox2
JVM class loading mechanism
力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
Cuda版本不一致,编译apex报错
使用高斯Redis实现二级索引
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
Gorilla official: sample code for golang to open websocket client
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Tp6 realize Commission ranking
openEuler 有奖捉虫活动,来参与一下?