javascript-php or JS to get the height of the picture

Source: Internet
Author: User
Such a page

  • ...
  • Each picture has a different width. There are ways to get the height of each picture. and fill in the height inside?
    For advice

    Reply content:

    Such a page

  • ...
  • Each picture has a different width. There are ways to get the height of each picture. and fill in the height inside?
    For advice

    PHP function getimagesize can get the picture width high information

    Array getimagesize (string $filename [, Array & $imageinfo])

    Returns an array with four cells. Index 0 contains the pixel value of the image width, and index 1 contains the pixel value of the image height. Index 2 is a marker of the image type: 1 = gif,2 = jpg,3 = png,4 = swf,5 = psd,6 = bmp,7 = TIFF (Intel byte order), 8 = TIFF (Motorola byte order), 9 = jpc,10 = jp2,11 = jpx,12 = jb2,13 = swc,14 = iff,15 = wbmp,16 = XBM. These tags correspond to the newly added IMAGETYPE constants of PHP 4.3.0. Index 3 is a text string with the content "height=" yyy "width=" xxx ", which can be used directly with the IMG tag.

    This is the PHP official website manual: Http://php.net/manual/en/function.get ...

    Add a Demo:

    $images _array = Array ("Http://static.zend.com/img/logo.gif"), foreach ($images _array as $image) {list ($width, $height, $type, $attr) = getimagesize ($image), $new _height = (int) (192/$width * $height); Echo '
  • ';}
  • Are you going to pin the picture in a box?

    Picture Adaptive//function Image_fix_to_box (obj,width,height) {var owidth = Obj.width;var Oheight = Obj.height;var R1 = parseFloat (obj.width)/parsefloat (obj.height), var r2 = parsefloat (width)/parsefloat (height), if (Math.Abs (R1-R2) < 0.0001) {OB J.width = Width;obj.height = height;} else if (R1 < r2) {obj.height = Height;obj.width = parseint (parsefloat (height)/parsefloat (oheight)  * owidth);} Else{obj.width = Width;obj.height = parseint (parsefloat (width)/parsefloat (owidth) * oheight);}}

    There are two ways to find jquery:
    1,http://www.cssrain.cn/?p=108
    2,http://www.hake.cc/a/biancheng/web/js ...

  • 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.