代码收藏

收集网站开发时常用到的代码(asp,php,js等)

« trim-截取两边空格thumb-创建图片缩略图 »

photoCreateCropThumb-生成图片缩略图

function photoCreateCropThumb ($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 75) {
  
    $pic = @imagecreatefromjpeg($p_photo_file);

    if ($pic) {
        $thumb = @imagecreatetruecolor ($p_max_size, $p_max_size) or die ("Can't create Image!");
        $width = imagesx($pic);
        $height = imagesy($pic);
        if ($width < $height) {
                $twidth = $p_max_size;
                $theight = $twidth * $height / $width; 
                imagecopyresized($thumb, $pic, 0, 0, 0, ($height/2)-($width/2), $twidth, $theight, $width, $height); 
        } else {
                $theight = $p_max_size;
                $twidth = $theight * $width / $height; 
                imagecopyresized($thumb, $pic, 0, 0, ($width/2)-($height/2), 0, $twidth, $theight, $width, $height); 
        }

        ImageJPEG ($thumb, $p_thumb_file, $p_quality);
    }

}

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80605

Copyright 2008 ITlearner. Some Rights Reserved.