Home > php教程 > php手册 > PHP等比例生成缩略图

PHP等比例生成缩略图

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:57:06
Original
876 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 //复制图象 if(!@imagecopyresampled($new_pic,$pic_creat,0,0,0,0,$re_width,$re_height,$pic_scal_arr[0],$pic_scal_arr[1])){ return false; } //输出文件 $out_file = ''; switch($pic_sca

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

 

  //复制图象

  if(!@imagecopyresampled($new_pic,$pic_creat,0,0,0,0,$re_width,$re_height,$pic_scal_arr[0],$pic_scal_arr[1])){

  return false;

  }

  //输出文件

  $out_file = '';

  switch($pic_scal_arr['mime']){

  case 'image/jpeg':

  $out_file = @imagejpeg($new_pic,$file_new);

  break;

  case 'image/jpg':

  $out_file = @imagejpeg($new_pic,$file_new);

  break;

  case 'image/gif':

  $out_file = @imagegif($new_pic,$file_new);

  break;

  case 'image/bmp':

  $out_file = @imagebmp($new_pic,$file_new);

  break;

  default:

  return false;

  break;

  }

  if($out_file){

  return true;

  }else{

  return false;

  }

  参数说明:

  $file_name:原始图片的路径

  $file_new:缩略图路径

  调用:

  php

  $file_name='C:\123.jpg';

  $file_new='C:\new.jpg';

  scal_pic($file_name,$file_new);

  ?>

  这里根据自己的需要可以将上传好的图片路径传过来,本例运行后在C盘下会生成一张名为new.jpg的小图片。

  [1] [2] 

PHP等比例生成缩略图

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template