js獲取圖片尺寸與圖片大小寬度
這是一款利用了js獲取圖片尺寸與圖片大小寬度哦,第一款實例可以獲取圖片大小,第二款根據圖片大小彈出一個同樣大小的預覽視窗。
<script language=網頁特效>
function index_image_valid(){
document.pho_up.indeximg.src=document.pho_up.pho_index.value;
imagewidth=document.pho_up.indeximg.width;
imageheigth=document.pho_up.indeximg.height;
alert ("寬:"+imagewidth+"n高:"+imageheigth);
}
</script>
</head>
<form name="pho_up" method="post" enctype="multipart/form-data">
<input type="file" name="pho_index" size="20" class=input onchange="javascript:index_image_valid();" >
<img name=indeximg>
</form>
方法二
<html>
<head>
<title>顯示圖片尺寸</title>
<script language="javascript" >
<!--
function preview(src)
{
newwindow =window.open('','newwindow','menubar=0,toolbar=0, location=0,directories=0,status=0,scrollbars=0,resizable=1');
newwindow.document.open();
newwindow.document.write('<html><body bgcolor="#cccccc">');
newwindow.document.write('<div align="center"><img src="'+src+'" name="img"></div><br >');
width = newwindow.document.images['img'].width;
height = newwindow.document.images['img'].height;
newwindow.document.write('檔尺寸;' +width+'*'+height);
if (width>100 && height>100)
newwindow.resizeto(width+100, height+100);
else
newwindow.resizeto(300,300);
}
//-->
</script>
</head>
<body>
<p align="center">檔位置
<input type="file" name="newsimage" onchange="javascript:preview(this.value)">
</p>
</body>
</html>
php教程
<?
$arr=getimagesize("images/album_01.gif");
echo $arr[3];
$strarr=explode(""",$arr[3]);
echo $strarr[1];
?>