JS get picture size and picture size width

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax document example file function get html javascript

JS get picture size and picture size width
This is a use of JS get picture size and picture size width Oh, the first example can get picture size, the second according to the size of the picture pops up a preview window of the same size.
<script language= Web page Special effects >

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 ("Wide:" +imagewidth+ "N High:" +imageheigth);


  }  


&lt;/script&gt;


&lt;/head&gt;


&lt;form name= "pho_up" method= "post" enctype= "Multipart/form-data" &gt;


&lt;input type= "File" Name= "Pho_index" size= "Class=input onchange=" Javascript:index_image_valid (); " &gt;


&lt;img name=indeximg&gt;


&lt;/form&gt;



Method Two

  <HTML>
<head>
<title> Show picture dimensions </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 (' File size; ' +width+ ' * ' +height);
if (width>100 && height>100)
      Newwindow.resizeto (width+100, HEIGHT+100);
Else
      Newwindow.resizeto (300,300);
}
//-->
</script>
</head>

<body>
<p align= "Center" > File location
<input type= "File" Name= "Newsimage" onchange= "Javascript:preview (this.value)" >
</p>
</body>
</html>

PHP Tutorials
?

$arr =getimagesize ("Images/album_01.gif");


echo $arr [3];


$strarr =explode ("" ", $arr [3]);


echo $strarr [1];


?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.