本篇文章主要说明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文件中标记中的 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;
输出信息如下:
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内存消耗量以实现程序的性能优化

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
