Home  >  Article  >  Backend Development  >  Generate Thumbnails_PHP Tutorial

Generate Thumbnails_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 16:09:48753browse


Generate thumbnails $tx=GetImageSize($sample);
if($tx[0]<=$tx[1] and $tx[1]>=120){
$height=120;
$width=intval($height*$tx[0]/$tx[1]);
}
if($tx[0]>=$tx[1] and $tx[0]> ;=100){
$width=100;
$height=intval($width*$tx[1]/$tx[0]);
}
if($tx[0 ]<100 and $tx[1]<120){
$width=$tx[0];
$height=$tx[1];
}

makethumb2 ($sample,$target,$width,$height);

// $srcFile: Source file
// $dstFile: Target file
// $dstW: Target image width
// $dstH: target file height
function makethumb2($srcFile,$dstFile,$dstW,$dstH){
$data=GetImageSize($srcFile,&$info);
switch($ data[2]){
case 1:
$im=@ImageCreateFromGIF($srcFile);
break;
                     case 2:
                                                                                                                                                                                                                                                                           🎜>                                                                                                                                                                                                                                                     ImageSY($im);
                  $ni=ImageCreate($dstW,$dstH); srcH);
              ImageJpeg($ni,$dstFile);                                                                                                                                 ’ ’ s ’   ’ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​, just change the last sentence
}



http://www.bkjia.com/PHPjc/314377.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/314377.html

TechArticle

Statement:
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