Forum Moderators: coopster

Message Too Old, No Replies

Using imagettftext() on the fly vs. just once

         

ccarlson

9:11 pm on Aug 1, 2007 (gmt 0)

10+ Year Member



I'm trying to find out how significant a difference in processing required to display text on an image using imagettftext. If I have a site where I want to display text on different images that will be viewed possibly hundreds or even thousands of times a day, is it better to process the images once initially and save the image so that all subsequent views will have the text, or is it insignificant to just use imagettftext each time an image is viewed. I ask this because the advantage of NOT saving the images with the text is that if I decide to change it later I can. But, if it's going to take a big processing hit, then I'd rather save the images with the text. Would appreciate some opinions. Also, is there any other consideration such as memory leaks or anything?

RonPK

8:18 am on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest to use a caching procedure:

if (cached version exists && cached version not older than 1 day) { 
echo cached version;
} else {
create image with text;
store image in cache;
echo image;
}

That saves you from the image creation overhead and enables future text modifications.