GD error while try load font

时光总嘲笑我的痴心妄想 提交于 2019-12-12 12:32:49

问题


I try load font by imageloadfont function. When I running script I receive error:

gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
PHP Warning:  imageloadfont(): Error reading font, invalid font header

What can cause this problem?

Env:

Ubuntu 13.04 64-bit

PHP 5.4.9-4ubuntu2.3


回答1:


I saw this error while trying to randomly use one of the system's .ttf file. The PHP Manual example has .gdf font file.

My image dimensions are 1013 x 638 (646294 pixels), an ID card sized image in 300 dpi.

PHP_INT_MAX in my case has a value of 2147483647 and memory limit set to 128 MB.

The converted new font file worked (.gdf format font)

Font converter: www.wedwick.com/wftopf.exe

Source: http://www.animeviews.com/article.php?ID=263




回答2:


I found the solution. The problem wasn't in the imageloadfont function.

I was trying to load the font (.ttf) to imageloadfont and set it on the image. Instead of using the imagestring function, I now used imagettftext to load the custom font and place the string on the picture.



来源:https://stackoverflow.com/questions/19196412/gd-error-while-try-load-font

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!