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

8 CAS

Some important knowledge of MySQL

Introduction to bit operation

Compiler optimization (4): inductive variables

Ways to improve the utilization of openeuler resources 01: Introduction

Force buckle 599 Minimum index sum of two lists

PMP practice once a day | don't get lost in the exam -7.7

CSDN语法说明

CSDN syntax description

Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
随机推荐
搞定带WebKitFormBoundary post登录
JVM 类加载机制
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
强化学习-学习笔记8 | Q-learning
使用高斯Redis实现二级索引
Semantic slam source code analysis
力扣 1232.缀点成线
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
Ucloud is a basic cloud computing service provider
毕业季|遗憾而又幸运的毕业季
A pot of stew, a collection of common commands of NPM and yarn cnpm
Force buckle 599 Minimum index sum of two lists
831. KMP string
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
【STL】vector
Boot 和 Cloud 的版本选型
力扣 2315.统计星号
mock. JS returns an array from the optional data in the object array
LeetCode_7_5
Simulate the implementation of string class