我試圖創建與下面的代碼ImageMagick的一個PNG。問題寫文字到圖像使用PHP的ImageMagick
<?php
/* Create some objects */
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel('gray');
/* New image */
$image->newImage(800, 75, $pixel);
/* Black text */
$draw->setFillColor('black');
/* Font properties */
$draw->setFont('Oxin_free_promo.ttf');
$draw->setFontSize(30);
/* Create text */
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox jumps over the lazy dog');
/* Give image a format */
$image->setImageFormat('png');
/* Output the image with headers */
header('Content-type: image/png');
echo $image;
但是我不斷收到下面的錯誤。/usr/local/zend/tmp /被chmod改爲777,並由守護進程擁有:zend和magick- *不存在。有任何想法嗎?
httpd: FreeType library is not available `/Users/gareth.williams/Sites/_tests/texttoimg/Oxin_free_promo.ttf'.
httpd: Postscript delegate failed `/usr/local/zend/tmp/magick-tmfNBDIx': No such file or directory.
PHP Fatal error: Uncaught exception 'ImagickException' with message 'Unable to annotate image'
沒有你的網站服務器的用戶ID必須對../tmp文件夾的寫權限? –
試試這個:sudo chmod 777/usr/local/zend/tmp/ – aykut
在更改服務器設置之前,您應該嘗試找出Imagick創建臨時文件的原因,而不是僅在內存中工作! – emartel