当前位置:网站首页>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 .
边栏推荐
- Force buckle 912 Sort array
- 开源OA开发平台:合同管理使用手册
- Implement secondary index with Gaussian redis
- [sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
- 841. 字符串哈希
- 【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
- LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
- Notes...
- Mysql, sqlserver Oracle database connection mode
- 华南X99平台打鸡血教程
猜你喜欢

MRS离线数据分析:通过Flink作业处理OBS数据

Yolov6:yolov6+win10--- train your own dataset

Data island is the first danger encountered by enterprises in their digital transformation

Force buckle 2319 Judge whether the matrix is an X matrix

ASP. Net learning & ASP's one word

剑指 Offer II 013. 二维子矩阵的和

Simulate the implementation of string class

使用高斯Redis实现二级索引

开源OA开发平台:合同管理使用手册

RESTAPI 版本控制策略【eolink 翻译】
随机推荐
力扣 2315.统计星号
MSE API学习
力扣 459. 重复的子字符串
【STL】vector
sql 常用优化
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
Ways to improve the utilization of openeuler resources 01: Introduction
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
pom. Brief introduction of XML configuration file label function
R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified
Kubernetes——kubectl命令行工具用法详解
使用高斯Redis实现二级索引
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
Implement secondary index with Gaussian redis
A pot of stew, a collection of common commands of NPM and yarn cnpm
Cloud component development and upgrading
CSDN语法说明
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Some important knowledge of MySQL
Force buckle 1961 Check whether the string is an array prefix