) public function thumb($filename,$new_w=160,$new_h=120,$cut=0,$big=0){ // 获取原图信息 $info = $this->getImageInfo($this->img); if(!empty($info[0])) { $old_w = $info[0]; $old_h = $info[1]; $type = $info['type']; $ext = $info['ext']; unset($info); // 如果原图比缩略图小 并且不允许放大 if($old_w < $new_h && $old_h < $new_w && !$big){ return false; } // 裁剪图片 if($cut == 0){ // 等比列 $scale = min($new_w/$old_w, $new_h/$old_h); // 计算缩放比例 $width = (int)($old_w*$scale); // 缩略图尺寸 $height = (int)($old_h*$scale); $start_w = $start_h = 0; $end_w = $old_w; $end_h = $old_h; } elseif($cut == 1){ // center center 裁剪 $scale1 = round($new_w/$new_h,2); $scale2 = round($old_w/$old_h,2); if($scale1 > $scale2){ $end_h = round($old_w/$scale1,2); $start_h = ($old_h-$end_h)/2; $start_w = 0; $end_w = $old_w; } else{ $end_w = round($old_h*$scale1,2); $start_w = ($old_w-$end_w)/2; $start_h = 0; $end_h = $old_h; } $width = $new_w; $height= $new_h; } elseif($cut == 2){ // left top 裁剪 $scale1 = round($new_w/$new_h,2); $scale2 = round($old_w/$old_h,2); if($scale1 > $scale2){ $end_h = round($old_w/$scale1,2); $end_w = $old_w; } else{ $end_w = round($old_h*$scale1,2); $end_h = $old_h; } $start_w = 0; $start_h = 0; $width = $new_w; $height= $new_h; } // 载入原图 $createFun = 'ImageCreateFrom'.$type; $oldimg = $createFun($this->img); // 创建缩略图 if($type!='gif' && function_exists('imagecreatetruecolor')){ $newimg = imagecreatetruecolor($width, $height); } else{ $newimg = imagecreate($width, $height); } // 复制图片 if(function_exists("ImageCopyResampled")){ ImageCopyResampled($newimg, $oldimg, 0, 0, $start_w, $start_h, $width, $height, $end_w,$end_h); } else{ ImageCopyResized($newimg, $oldimg, 0, 0, $start_w, $start_h, $width, $height, $end_w,$end_h); } // 对jpeg图形设置隔行扫描 $type == 'jpeg' && imageinterlace($newimg,1); // 生成图片 $imageFun = 'image'.$type; !@$imageFun($newimg,$filename) && die('保存失败!检查目录是否存在并且可写?'); ImageDestroy($newimg); ImageDestroy($oldimg); return $filename; } return false; } // water(保存地址,水印图片,水印位置,透明度) public function water($filename,$water,$pos=0,$pct=80){ // 加载水印图片 $info = $this->getImageInfo($water); if(!empty($info[0])){ $water_w = $info[0]; $water_h = $info[1]; $type = $info['type']; $fun = 'imagecreatefrom'.$type; $waterimg = $fun($water); } else{ return false; } // 加载背景图片 $info = $this->getImageInfo($this->img); if(!empty($info[0])){ $old_w = $info[0]; $old_h = $info[1]; $type = $info['type']; $fun = 'imagecreatefrom'.$type; $oldimg = $fun($this->img); } else{ return false; } // 剪切水印 $water_w >$old_w && $water_w = $old_w; $water_h >$old_h && $water_h = $old_h; // 水印位置 switch($pos){ case 0://随机 $posX = rand(0,($old_w - $water_w)); $posY = rand(0,($old_h - $water_h)); break; case 1://1为顶端居左 $posX = 0; $posY = 0; break; case 2://2为顶端居中 $posX = ($old_w - $water_w) / 2; $posY = 0; break; case 3://3为顶端居右 $posX = $old_w - $water_w; $posY = 0; break; case 4://4为中部居左 $posX = 0; $posY = ($old_h - $water_h) / 2; break; case 5://5为中部居中 $posX = ($old_w - $water_w) / 2; $posY = ($old_h - $water_h) / 2; break; case 6://6为中部居右 $posX = $old_w - $water_w; $posY = ($old_h - $water_h) / 2; break; case 7://7为底端居左 $posX = 0; $posY = $old_h - $water_h; break; case 8://8为底端居中 $posX = ($old_w - $water_w) / 2; $posY = $old_h - $water_h; break; case 9://9为底端居右 $posX = $old_w - $water_w; $posY = $old_h - $water_h; break; default: //随机 $posX = rand(0,($old_w - $water_w)); $posY = rand(0,($old_h - $water_h)); break; } // 设定图像的混色模式 imagealphablending($oldimg, true); // 添加水印 imagecopymerge($oldimg, $waterimg, $posX, $posY, 0, 0, $water_w,$water_h,$pct); $fun = 'image'.$type; !@$fun($oldimg, $filename) && die('保存失败!检查目录是否存在并且可写?'); imagedestroy($oldimg); imagedestroy($waterimg); return $filename; } } ?> tamron - Gogs: Go Git Service

Нет описания

Brightcells: 1db38b5f89 Initial лет %!s(int64=8): %!d(string=назад)
..
image 1db38b5f89 Initial лет %!s(int64=8): %!d(string=назад)
pai2 - Gogs: Go Git Service

拍爱

Brightcells: da19301800 Update set_brief_info after origin photo upload 10 lat temu
..
__init__.py 7a17d0fb90 add api wxpay & add redis relative 10 lat temu
rapp.py 27d3ec8fb1 add src for LatestAppInfo/SplashInfo 10 lat temu
rbrief.py da19301800 Update set_brief_info after origin photo upload 10 lat temu
retrieve.py 86aa86bbba add GROUP_PHOTO_WATCHER_SET 10 lat temu
rgroup.py ba8098eaae fix bug: get_group_users_info error when not in redis 10 lat temu
rguest.py dd00e3b1a9 add api online_api 10 lat temu
rkeys.py d79857ed0e lensman balance decr when origin deleted & update redis 10 lat temu
rmessage.py fabef63211 set line_length=200 for isort 10 lat temu
rorder.py fabef63211 set line_length=200 for isort 10 lat temu
rprice.py 684b876a38 price_fixed store in redis & update api lensman_photo_price 10 lat temu
rsettings.py e4c95c78c7 tstrip 10 lat temu
ruuid.py d73fdb7cd2 async/multi_pop uuids 10 lat temu
kodo - Gogs: Go Git Service

Brak opisu

huangqimin: d659c6e1e2 :art: TimeConvert local_string utc_dt 6 lat temu
..
roperation afd07e5389 Add api box_program_version_api 9 lat temu
__init__.py 7a17d0fb90 add api wxpay & add redis relative 10 lat temu
connect.py 246a9ff4b8 Change to 'from utils.redis.connect import r' 9 lat temu
rapp.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rbrief.py d659c6e1e2 :art: TimeConvert local_string utc_dt 6 lat temu
retrieve.py fc46e64646 Send msg to self when thumbup and comment 9 lat temu
rgroup.py fc46e64646 Send msg to self when thumbup and comment 9 lat temu
rguest.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rkeys.py 714f03e3d9 :art: Opt MEMBERCARD_USERINFO_LIST 6 lat temu
rlock.py f2fc73685d Update package django_xxx 8 lat temu
rmessage.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rorder.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rpatch.py 597ee33ba6 Pai2 => Kodo 8 lat temu
rprice.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rprofile.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rsettings.py 597ee33ba6 Pai2 => Kodo 8 lat temu
rshot.py 211ab99a32 :art: member/user/coupon/detail & member/user/coupon/use 6 lat temu
rtourguide.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
rtouruser.py 2eba3ed7f9 Add guest login for tourguide 9 lat temu
ruuid.py 6cc1a44274 Change curtail_uuid to django_curtail_uuid 8 lat temu