当前位置:网站首页>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 .
边栏推荐
- Browse the purpose of point setting
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
- YoloV6:YoloV6+Win10---训练自己得数据集
- 【STL】vector
- Force buckle 1232 Dotted line
- 力扣 989. 数组形式的整数加法
- 有了ST7008, 蓝牙测试完全拿捏住了
- Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
- openEuler 有奖捉虫活动,来参与一下?
- 力扣 88.合并两个有序数组
猜你喜欢
Welcome to the markdown editor
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Introduction to bit operation
Nunjuks template engine
微信公众号OAuth2.0授权登录并显示用户信息
The project manager's "eight interview questions" is equal to a meeting
Make this crmeb single merchant wechat mall system popular, so easy to use!
Simulate the implementation of string class
9 atomic operation class 18 Rohan enhancement
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
随机推荐
Some important knowledge of MySQL
MRS离线数据分析:通过Flink作业处理OBS数据
JVM class loading mechanism
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
Force buckle 989 Integer addition in array form
Ucloud is a basic cloud computing service provider
8 CAS
Cloud 组件发展升级
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
强化学习-学习笔记8 | Q-learning
Kubernetes——kubectl命令行工具用法详解
Vulnhub's funfox2
Compiler optimization (4): inductive variables
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
IP tools
CIS芯片测试到底怎么测?
RESTAPI 版本控制策略【eolink 翻译】
Force buckle 1790 Can two strings be equal by performing string exchange only once
Force buckle 459 Duplicate substring
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决