Reputation: 23
the php gd imagettftext function can only load true type fonts from a file. Is there a way that I can load it in from memory? For example I pull the file from a DB and pass the string of bytes into it somehow?
Only other option I can think of is to load the file from the db, write it to disk (if it doesn't already exist), and then load it /w imagettftext. Is there a better way?
Upvotes: 2
Views: 278
Reputation: 14329
I believe you are forced to read from the file system with GD. Even implementing a custom stream wrapper didn't help; GD evidently doesn't make use of PHP's stream system and simply loads the file itself.
What you may want to do is use another language with an image processing library that can accomplish what you need. You will be able to serve up your web pages using PHP and serve up your images using something else.
Upvotes: 1
Reputation: 2924
A temp file sounds like a pretty sound idea however I question why you would want to store it in a database. It's going to be far more efficient to store all those TTF's in a directory somewhere. I would then just store the path/filename. That many temporary operations to write the temp files to disk could have some considerable negative effects in a high load environment.
Upvotes: 1
Reputation: 341
I recommend to store all binary files on the filesystem and store paths to those files on database. Database is not a place for binary files.
Upvotes: 2