国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - Php Image Resize圖片大小調整的函數代碼

Php Image Resize圖片大小調整的函數代碼

2019-11-16 13:00PHP教程網 PHP教程

php下可以將圖片大小調整的函數代碼,需要的朋友可以參考下。

代碼如下:


function my_image_resize($src_file, $dst_file, $dst_width=32, $dst_height=32) { 
if($dst_width <1 || $dst_height <1) { 
echo "params width or height error !"; 
exit(); 

if(!file_exists($src_file)) { 
echo $src_file . " is not exists !"; 
exit(); 


$type=exif_imagetype($src_file); 
$support_type=array(IMAGETYPE_JPEG , IMAGETYPE_PNG , IMAGETYPE_GIF); 

if(!in_array($type, $support_type,true)) { 
echo "this type of image does not support! only support jpg , gif or png"; 
exit(); 


switch($type) { 
case IMAGETYPE_JPEG : 
$src_img=imagecreatefromjpeg($src_file); 
break; 
case IMAGETYPE_PNG : 
$src_img=imagecreatefrompng($src_file); 
break; 
case IMAGETYPE_GIF : 
$src_img=imagecreatefromgif($src_file); 
break; 
default: 
echo "Load image error!"; 
exit(); 

$src_w=imagesx($src_img); 
$src_h=imagesy($src_img); 
$ratio_w=1.0 * $dst_width/$src_w; 
$ratio_h=1.0 * $dst_height/$src_h; 
if ($src_w<=$dst_width && $src_h<=$dst_height) { 
$x = ($dst_width-$src_w)/2; 
$y = ($dst_height-$src_h)/2; 
$new_img=imagecreatetruecolor($dst_width,$dst_height); 
imagecopy($new_img,$src_img,$x,$y,0,0,$dst_width,$dst_height); 
switch($type) { 
case IMAGETYPE_JPEG : 
imagejpeg($new_img,$dst_file,100); 
break; 
case IMAGETYPE_PNG : 
imagepng($new_img,$dst_file); 
break; 
case IMAGETYPE_GIF : 
imagegif($new_img,$dst_file); 
break; 
default: 
break; 

} else { 
$dstwh = $dst_width/$dst_height; 
$srcwh = $src_w/$src_h; 
if ($ratio_w <= $ratio_h) { 
$zoom_w = $dst_width; 
$zoom_h = $zoom_w*($src_h/$src_w); 
} else { 
$zoom_h = $dst_height; 
$zoom_w = $zoom_h*($src_w/$src_h); 


$zoom_img=imagecreatetruecolor($zoom_w, $zoom_h); 
imagecopyresampled($zoom_img,$src_img,0,0,0,0,$zoom_w,$zoom_h,$src_w,$src_h); 
$new_img=imagecreatetruecolor($dst_width,$dst_height); 
$x = ($dst_width-$zoom_w)/2; 
$y = ($dst_height-$zoom_h)/2+1; 
imagecopy($new_img,$zoom_img,$x,$y,0,0,$dst_width,$dst_height); 
switch($type) { 
case IMAGETYPE_JPEG : 
imagejpeg($new_img,$dst_file,100); 
break; 
case IMAGETYPE_PNG : 
imagepng($new_img,$dst_file); 
break; 
case IMAGETYPE_GIF : 
imagegif($new_img,$dst_file); 
break; 
default: 
break; 


延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 中文字幕二区 | 午夜激情影视 | 免费一级片在线观看 | 午夜精品久久 | 欧美日韩在线免费观看 | 欧美黄视频 | 不卡一区| 欧美精品在线一区二区三区 | 精品久久久久久久久久久久 | 成人a视频 | 亚洲福利在线观看 | 激情五月激情 | 久久精品片 | 日韩国产一区 | 精品欧美一区二区久久久伦 | 久久精品欧美 | 午夜影视 | 国产美女一区二区三区 | 中文一区 | 奇米av在线| 中文字幕亚洲欧美日韩在线不卡 | 久久精品网 | 亚洲国产aⅴ成人精品无吗 黄色免费在线看 | 欧美喷潮久久久xxxxx | 一区二区三区在线免费播放 | 欧美操穴 | 亚洲高清在线视频 | 免费裸体无遮挡黄网站免费看 | 日韩二区三区 | 久久精品久久综合 | av官网在线 | 国产精品免费观看 | 欧美日韩一区二区三区在线电影 | 中文字幕在线观看 | 激情综合色综合久久综合 | 毛片免费在线 | 黄色高清网站 | 一区二区三区视频免费在线观看 | 欧美另类视频在线 | 亚洲欧洲一区二区三区 | 超碰最新网址 |