当前位置:网站首页>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 .
边栏推荐
- JVM class loading mechanism
- MIT science and technology review article: AgI hype around Gato and other models may make people ignore the really important issues
- Yolov6:yolov6+win10--- train your own dataset
- 数据孤岛是企业数字化转型遇到的第一道险关
- R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize the violin diagram, set the palette parameter to customize the filling color of violin diagrams at different
- YoloV6:YoloV6+Win10---训练自己得数据集
- ASP. Net learning & ASP's one word
- School 1 of vulnhub
- Chapter 20 using work queue manager (3)
- Opencv学习笔记 高动态范围 (HDR) 成像
猜你喜欢
Sword finger offer II 013 Sum of two-dimensional submatrix
mysql 的一些重要知识
【STL】vector
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
力扣 2319. 判断矩阵是否是一个 X 矩阵
Some important knowledge of MySQL
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
【哲思与实战】程序设计之道
Yolov6:yolov6+win10--- train your own dataset
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
随机推荐
力扣 1037.有效的回旋镖
CSDN syntax description
Version selection of boot and cloud
力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
School 1 of vulnhub
Semantic slam source code analysis
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
Interpretation of transpose convolution theory (input-output size analysis)
vulnhub之tre1
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
机器学习笔记 - 使用Streamlit探索对象检测数据集
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
mysql 的一些重要知识
使用高斯Redis实现二级索引
Notes...
The boundary of Bi: what is bi not suitable for? Master data, Martech? How to expand?
How to cooperate among multiple threads
openEuler 有奖捉虫活动,来参与一下?
LeetCode_7_5