PHP:获取图像大小 [英] PHP: Obtaining Image Size

查看:116
本文介绍了PHP:获取图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写下一个函数,它接受一个参数,即服务器上图像的物理路径。我想知道是否有可能以任何方式获得其原始大小的像素。

I am writing down a function and it takes an argument which is the physical path of an image on server. I was wondering if it is possible in any way to obtain its original size in pixels.

在一个变量中,我想存储它的宽度,而在其他变量中存储它的高度。让我问这个的挑战是因为我必须在服务器端获取它,因此任何客户端解决方案都无济于事。

In one variable I would like to store its width and in other variable its height. The challenge that made me ask this is because I have to obtain it on server-side thus any client-side solution would not help.

推荐答案

尝试使用以下内容:

<?php
    $size = getimagesize ("img.jpg");
    echo "<img src=\"img.jpg\" {$size[3]}>";
?>

这篇关于PHP:获取图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆