Php or js get image size-PHP source code

Source: Internet
Author: User
Tags php source code
Ec (2); & lt ;? $Arrgetimagesize(&quot=imagesalbum_01.gif & quot;); echo $ arr [3]; $ strarrexplode (& quot;, $ arr [3]); echo $ strarr [1];? & Gt; & lt; HTML & gt; & lt; HEAD & gt; & lt; TITLE & gt; demo image comparison script ec (2); script

$ Arr = getimagesize ("images/album_01.gif ");
Echo $ arr [3];
$ Strarr = explode ("/" ", $ arr [3]);
Echo $ strarr [1];
?>



Scale down demo Images
Script
Function Wa_SetImgAutoSize (img)
{
// Var img = document. all. img1; // obtain the image
Var MaxWidth = 200; // sets the Image Width limit.
Var MaxHeight = 100; // sets the image height limit.
Var HeightWidth = img. offsetHeight/img. offsetWidth; // you can specify the aspect ratio.
Var WidthHeight = img. offsetWidth/img. offsetHeight; // set the aspect ratio.
Alert ("test" + img. offsetHeight + img. fileSize );
If (img. offsetHeight> 1) alert (img. offsetHeight );
If (img. readyState! = "Complete "){
Return false; // make sure the image is fully loaded.
}

If (img. offsetWidth> MaxWidth ){
Img. width = MaxWidth;
Img. height = MaxWidth * HeightWidth;
}
If (img. offsetHeight> MaxHeight ){
Img. height = MaxHeight;
Img. width = MaxHeight * WidthHeight;
}
}

Function CheckImg (img)
{
Var message = "";
Var MaxWidth = 1; // sets the Image Width limit.
Var MaxHeight = 1; // sets the image height limit.

If (img. readyState! = "Complete "){
Return false; // make sure the image is fully loaded.
}
If (img. offsetHeight> MaxHeight) message + = "/r height excess:" + img. offsetHeight;
If (img. offsetWidth> MaxWidth) message + = "/r width exceeded:" + img. offsetWidth;
If (message! = "") Alert (message );
}
Script







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.