ホームページ  >  記事  >  バックエンド開発  >  PHPサムネイル実装関数コード

PHPサムネイル実装関数コード

高洛峰
高洛峰オリジナル
2016-11-30 09:45:06957ブラウズ

array getimagesize ( string $filename [, array &$imageinfo ] ) 画像サイズを取得します
resource imagecreatetruecolor ( int $x_size , int $y_size ) 新しい True Color 画像を作成します
resource imagecreatefromjpeg ( string $filename ) 新しい画像を作成しますJPEG ファイルまたは URL 画像
bool imagecopyresize ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )画像の一部をコピーしてサイズを調整します
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 画像をブラウザまたは JPEG 形式のファイルに出力します
コードは次のとおりです。 ?php
/*
作成者 */
// ファイルとズームのサイズ
//$imgfile = 'smp.jpg'; /$percent = 0.2;
header('Content -type: image/jpeg') = getimagesize($imgfile); $height * $percent;
$thumb = ImageCreateTrueColor ($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresize($thumb, $source, 0, 0, 0, 0, $newwidth, $ newheight、$width、$height);
imagejpeg ($thumb);