tags:

views:

67

answers:

4

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?

+7  A: 

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.

cletus
also in PNG - there are various types. PNG-8, PNG-24, PNG-32. each has variations in the number of bits per pixel. JPEG you can also set the compression level in the `imagejpeg()` function
thephpdeveloper
It should be noted that both GIF so they are only lossless when your image has below 255 colours. When you have more colours, you will need to reduce the number to fit the format.
Lachlan McDonald
+1  A: 

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.

leonm
+1  A: 

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.

James Black
A: 

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...

txyoji