Question

I am using the GD Library to add text to the PNG Image of a Form, that i am using to create a pdf. My Tests show that using PNG, dosnt put to much of strain on the server just doing one, however i am concerned about scalability.

So my question is does working with one file type have more overhead, than any of the others?

Was it helpful?

Solution

You have three choices:

  • GIF: most backwards compatible, lossless;
  • PNG: better compression ratios than GIF, some issues on some browsers (like transparency on IE6); and
  • JPG: lossy format, typically used for photos.

So you should choose whichever is appropriate for what you're doing. I think you'd have to do a lot of them (like thousands) before the CPU differences would be a factor. Of these, GIF is probably the least and PNG the most (due to the compression algorithm) with JPG in the middle. But I can't envision the difference is substantial.

OTHER TIPS

There are many factors that will determine the overhead regardless of the file type.

The actual implementation of the algorithm will have big impact on performance. For example, even though bitmap is a simple format a badly written program can perform worse than a an optimized jpg library, even though it uses fourier transforms.

Another factor is disk io, which is generally expensive. Often the CPU compression takes less time than writing the uncompressed data to disk.

At this point the best advice is to run a load test with your estimated production load and see how things perform.

You may want to try doing a load test to see what type of strain you have, but, as cletus mentioned, the time to save the images is pretty inconsequential, but you may want to avoid JPEG as it is lossy and to have it be fast you wouldn't want it to have much compression.

If you have more than 256 colors then you will need PNG, but if you are using less than that then why not just use GIF and get the advantage of support across more browsers, if that is an issue.

PNG is the most portable.

If you install GD, you always have the supporting libraries for PNG.

That's not true for gif, jpeg, etc...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top