Home > php教程 > php手册 > 返回最佳图片的高度宽度

返回最佳图片的高度宽度

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 09:05:59
Original
819 people have browsed it
  •  //返回最佳图片的高度,宽度。以及原来的高度和宽度
    //$SrcH:原高度,$SrcW:原宽度,$DstH:目标高度,$DstW:目标宽度
    //调用时用 list($SrcW,$SrcH,$DstW,$DstH) = RtImageSize($ImgFile,200,200)
    function RtImageSize($ImgFile,$ImgW,$ImgH
    )
    {
            if(
    file_exists($ImgFile
    ))
            {
            
    $Size = @GetImageSize($ImgFile
    );
            
    $SrcW $Size[0
    ];
            
    $SrcH $Size[1
    ];
            
    $Ratio max($SrcW/$ImgW,$SrcH/$ImgH
    );
            
    $DstW = ($SrcW $Ratio
    );
            
    $DstH = ($SrcH $Ratio
    );
            }
            return array(
    $SrcW,$SrcH,$DstW,$DstH
    );
    }  


  • Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template