1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| // 获取原图属性 list($width, $height, $type, $attr) = getimagesizefromstring(pg_unescape_bytea($row[1])); $newWidth = $_GET['width']?$_GET['width']: $width; $newHeight = $height/$width * $newWidth;
$image =imagecreatefromstring(pg_unescape_bytea($row[1])); $quality = 0; // 图片输出质量,0 为最低
// Create a blank image and add some text $im = imagecreatetruecolor($newWidth, $newHeight); imagecopyresized($im,$image,0,0,0,0,$newWidth,$newHeight,$width,$height); // $text_color = imagecolorallocate($im, 233, 14, 91); // imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Set the content type header - in this case image/jpeg header('Content-Type: image/jpeg');
// Output the image imagejpeg($im, null, $quality);
// Free up memory imagedestroy($im);
|