Piotr Olaszewski
Piotr Olaszewski

Reputation: 6204

GD error while try load font

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

Upvotes: 3

Views: 3406

Answers (2)

Piotr Olaszewski
Piotr Olaszewski

Reputation: 6204

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.

Upvotes: 2

Bimal Poudel
Bimal Poudel

Reputation: 1234

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

Upvotes: 3

Related Questions