|
- <?php
- // File and new size
- $filename = 'test.jpg';
- $percent = 0.5;
- // Content type
- header('Content-Type: image/jpeg');
- // Get new sizes
- list($width, $height) = getimagesize($filename);
- $newwidth = $width * $percent;
- $newheight = $height * $percent;
- // Load
- $thumb = imagecreatetruecolor($newwidth, $newheight);
- $source = imagecreatefromjpeg($filename);
- // Resize
- imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
- // Output
- imagejpeg($thumb);
- ?>
复制代码
使用 imagecopyresampled 的圖片質量比 imagecopyresized 要好得多
|
|