Table of Contents
您可能感兴趣的文章
Home php教程 php手册 php获取图片尺寸(宽度,高度)

php获取图片尺寸(宽度,高度)

Jun 21, 2016 am 08:47 AM
echo height image

本篇文章主要说明PHP获取图片尺寸(宽度,高度)的函数,即getimagesize()函数。

语法:array getimagesize( string filename [, array &imageinfo] )

功能:getimagesize()函数将测定任何GIF,JPG,PNG,SWF,SWC,PSD,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM或WBMP图像文件并返回文件的大小,尺寸,文件类型以及一个可以用于普通HTML文件中php获取图片尺寸(宽度,高度)标记中的 height/width 文本字符串。如果不能访问指定的图像或者其不是有效的图像,getimagesize()将返回FALSE并产生一条E_WARNING级的错误。

注:

(1)本函数不需要 GD 图像库支持。

(2)该函数除了可以获取本地图片或者Flash的相关信息外还可以直接用来获取远程的。

示例:

<?php
list($width,$height,$type,$attr)=getimagesize("http://www.Alixixi.com/images/logo.gif");
echo "Image width ".$width;
echo "<br/>";
echo "Image height ".$height;
echo "<br/>";
echo "Image type ".$type;
echo "<br/>";
echo "Attribute ".$attr;
Copy after login

输出信息如下:

Image width 200
 
Image height 55
 
Image type 1
 
Image attribute width="200" height="55"

其中图片类型的参数参考如下:
 
1 = GIF  5 = PSD  9 = JPC  13 = SWC
 
2 = JPG  6 = BMP  10 = JP2  14 = IFF
 
3 = PNG  7 = TIFF(intel byte order)  11 = JPX  15 = WBMP
 
4 = SWF  8 = TIFF(motorola byte order)  12 = JB2  16 = XBM

您可能感兴趣的文章

  • php获取客户端电脑屏幕宽度,高度,分辨率的方法
  • Js地址栏特效(显示页面内所有加链接的图片的大小和查看当前的浏览器的高度)
  • javascript获取图片的宽度和高度的一种方法
  • 强大的PHP 图片处理类(水印、透明度、缩放、锐化、旋转、翻转、剪切、反色)
  • php获取远程图片并下载保存到本地
  • PHP如何判断一个gif图片是否为动态图片(动画)
  • 文本区域textarea框根据输入内容自适应高度
  • 用PHP函数memory_get_usage获取当前PHP内存消耗量以实现程序的性能优化



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Bing Image Creator for free How to use Bing Image Creator for free Feb 27, 2024 am 11:04 AM

This article will introduce seven ways to get high-quality output using the free BingImageCreator. BingImageCreator (now known as ImageCreator for Microsoft Designer) is one of the great online artificial intelligence art generators. It generates highly realistic visual effects based on user prompts. The more specific, clear, and creative your prompts are, the better the results will be. BingImageCreator has made significant progress in creating high-quality images. It now uses Dall-E3 training mode, showing a higher level of detail and realism. However, its ability to consistently produce HD results depends on several factors, including fast

How to delete images from Xiaomi phones How to delete images from Xiaomi phones Mar 02, 2024 pm 05:34 PM

How to delete images on Xiaomi mobile phones? You can delete images on Xiaomi mobile phones, but most users don’t know how to delete images. Next is the tutorial on how to delete images on Xiaomi mobile phones brought by the editor. Interested users can come and join us. Let's see! How to delete images on Xiaomi mobile phone 1. First open the [Album] function in Xiaomi mobile phone; 2. Then check the unnecessary pictures and click the [Delete] button in the lower right corner; 3. Then click [Album] at the top to enter the special area , select [Recycle Bin]; 4. Then directly click [Empty Recycle Bin] as shown in the figure below; 5. Finally, directly click [Permanent Delete] to complete.

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

In today's era of rapid technological development, programming languages ​​are springing up like mushrooms after a rain. One of the languages ​​that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Jun 13, 2023 pm 05:01 PM

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

&quot;Go Language Development Essentials: 5 Popular Framework Recommendations&quot; As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

Detailed explanation of the role and usage of the echo keyword in PHP Detailed explanation of the role and usage of the echo keyword in PHP Jun 28, 2023 pm 08:12 PM

Detailed explanation of the role and usage of the echo keyword in PHP PHP is a widely used server-side scripting language, which is widely used in web development. The echo keyword is a method used to output content in PHP. This article will introduce in detail the function and use of the echo keyword. Function: The main function of the echo keyword is to output content to the browser. In web development, we need to dynamically present data to the front-end page. At this time, we can use the echo keyword to output the data to the page. e

What are the most popular golang frameworks on the market? What are the most popular golang frameworks on the market? Jun 01, 2024 pm 08:05 PM

The most popular Go frameworks at present are: Gin: lightweight, high-performance web framework, simple and easy to use. Echo: A fast, highly customizable web framework that provides high-performance routing and middleware. GorillaMux: A fast and flexible multiplexer that provides advanced routing configuration options. Fiber: A performance-optimized, high-performance web framework that handles high concurrent requests. Martini: A modular web framework with object-oriented design that provides a rich feature set.

Imagemagic installation Centos and Image installation tutorial Imagemagic installation Centos and Image installation tutorial Feb 12, 2024 pm 05:27 PM

LINUX is an open source operating system. Its flexibility and customizability make it the first choice of many developers and system administrators. In the LINUX system, image processing is a very important task, and Imagemagick and Image are Two very popular image processing tools, this article will introduce you to how to install Imagemagick and Image in Centos system, and provide detailed installation tutorials. Imagemagic installation Centos tutorial Imagemagick is a powerful image processing toolset, which can perform various image operations under the command line. The following are the steps to install Imagemagick on Centos system: 1

See all articles