简体   繁体   English

php gd图像质量

[英]php gd image quality

I 'm trying to add text on a specific image. 我正在尝试在特定图像上添加文本。 Its working perfectly but the quality of image is low especially for papyrus.ttf font. 它工作正常,但图像质量特别低,尤其是对于papyrus.ttf字体。 How can i improve the quality of text in the image. 如何提高图像中文字的质量。 But i need high quality to print the output. 但是我需要高质量来打印输出。 Here is my code.. its very simple. 这是我的代码..它非常简单。

header("Content-Type: image/jpeg");
$im = imagecreatefromjpeg("cosmos.jpg");  
$black = ImageColorAllocate($im, 0, 0, 0);
Imagettftext($im, 14, 0, 10, 15, $black, 'papyrus.ttf', "Corey and Lisa ");
Imagettftext($im, 14, 0, 10, 35, $black, 'papyrus.ttf', " 1994, june");
Imagejpeg($im, '', 100);
ImageDestroy($im);

Download: http://wneeds.com/gdtest.zip 下载: http : //wneeds.com/gdtest.zip

If imageTTFText fails in Quality, the next step to try is ImageFTText() . 如果imageTTFText质量失败,则下一步是ImageFTText() It uses the FreeType library to render fonts, which usually means significantly better quality. 它使用FreeType库来呈现字体,这通常意味着明显更好的质量。 It needs to be installed and compiled into PHP to work, which it most often is. 它需要安装并编译成PHP才能正常工作,通常是这样。 Try calling the function and you'll see whether that is the case. 尝试调用该函数,您将看到情况是否如此。

If that doesn't do, the next step is using ImageMagick either through the command line, or through the appropriate PHP extension. 如果这样做不行,则下一步是通过命令行或通过适当的PHP扩展使用ImageMagick But try Freetype first, it could already be enough. 但是先尝试Freetype,就已经足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM