Image formats

Pages: 12
Mar 20, 2010 at 8:02pm
I was bored so I came up with this list of the only image formats I think are worthy of existance.

PNG (Portable Network Graphics) (pronounced: ping) (.png):
PNG is my favourite image file format because

- Has a fantastic compression ratio (better than JPEG sometimes)
- Brilliant quality (better than GIF, FAR better than JPEG)
- Alpha channel (transparency) (JPEG has no alpha channel)
- Interlacing
- Widely supported by web browsers

SVG (Scalable Vector Graphics) (pronounced: S-V-G) (.svg):
SVG is an extremely useful image format:

- One-size-fits-all
- Can be hand-written (XML)
- Alpha channels

But there are also problems with SVG:

- Because SVG files are plain-text XML files, they cannot be compressed
- SVG files are dynamically generated based on XML; so the XML has to be
- Tokenized
- Parsed
- Turned into a bitmap file
- Displayed

TGA (Targa) (pronounced: Targa) (.tga):
To be honest, the only thing I like about TGA is that it's supposedly very
easy to implement.

GIF (Graphics Interchange Format) (pronounced: Jiff) (.gif):
Again, the only thing I like about GIF is that GIF files can contain animations.
I don't think any other formats can do this.

What are your opinions?
Mar 20, 2010 at 8:18pm
closed account (z05DSL3A)
I would include JPEG2000, far better than PNG.
Mar 20, 2010 at 8:27pm
Does it have interlacing and alpha-channel support?
Mar 20, 2010 at 8:34pm
closed account (z05DSL3A)
Yes, and yes.

http://en.wikipedia.org/wiki/JPEG_2000
Mar 20, 2010 at 10:21pm
Looks very difficult to implement...
Mar 20, 2010 at 11:15pm
GIF --
Last edited on Mar 20, 2010 at 11:15pm
Mar 21, 2010 at 12:16am
Is that a decrement?
Mar 21, 2010 at 12:25am
yes. I know it doesn't look good

neither GIFs or my previous post
Mar 21, 2010 at 12:30am
You forgot the
-moves head in z shape while clicking fingers and humming-
Mar 21, 2010 at 12:49am
JSYK, text files typically compress better than binary data.


I like TGA, but it has the fabled file types 32 and 33, which don't exist. (I've asked Truevision for information on them, but they don't care.) Sooner or later I'll post some TGA code on Sourceforge that implements a type 32 compression so everyone can use it. :-)

Lack of serious compression is what really hurts TGAs.

TGA is much more flexible than people give it credit for. However, there are certain reasonable conventions that keep it fairly narrowly defined. It is very easy to write a decompressor for it, particularly if you plan to keep to a specific class of input types.


GIF is also a very nice compression format. Unfortunately, everyone believes it is limited to 256 colors, and as a result it is very restricted in industry use. Modern browsers will tend to do things to a GIF display that it shouldn't when given truecolor input file.


I like PNG, but besides writing a decoder for it I've not played with it too much.

PNG beats the pants off of GIF in compression ratios. (5% to 25% better file size -- my own testing averaged at about a 20% improvement.)


I know nothing about JPEG2000. It appears to be much too complex for my liking. I don't like a lot of overhead... (Which is why I like the first three so much.)


Also, don't forget TIFF. It is heavily used in the industry, and cannot be discounted. Unlike any other format mentioned here, TIFF has support for useful color spaces. It is, however, a really bastardized beast, and so becomes an awful burden to support.


I just visited http://en.wikipedia.org/wiki/Image_file_formats to see if I had forgotten anything, so I'll just leave it for you to visit. The only thing I notice there is that the page replicates the error about GIF supporting only 256 colors...


Ultimately, each format exists because of the domain for which it is useful. If I were working to produce trading cards for the next Pokemon set, I wouldn't use anything but TIFF. If I were a photographer, I would stick with JPEG or JPEG 2000. Web developers will stick to GIFs, PNGs, and JPEGs. Graphic designers will use SVG or other vector formats. For each case, using something else would be like trying to shoe a horse with a rubber tire. It makes no sense.

My $0.03
Mar 21, 2010 at 2:10am
I don't think any other formats can do [animations]


MNG, APNG. Though neither are as widespread or established as GIF.

I would include JPEG2000, far better than PNG.


You can't really say this. I mean it's not fair to either one.

JPEG2000 is lossy
PNG is lossless

The two have entirely different applications.


EDIT: actually I guess JPEG2000 can do lossless to. I didn't realize that. Still it doesn't seem to do lossless quite as well as png.
Last edited on Mar 21, 2010 at 2:11am
Mar 21, 2010 at 4:55am
Because SVG files are plain-text XML files, they cannot be compressed
Sure they can. It's called SVGZ.

I find the lack of JPEG and raw in this thread, disturbing. JPEG does great for photographs and any picture without sharp edges. There's few things I hate more than seeing someone uploaded a photo as a 2 MiB+ PNG.
And raw is great when you just need a simple format for temporary storage. I use it to cache rendered SVGs to disk, since it's usually a lot cheaper than keeping the loaded SVG around (a 150 KiB SVG can explode to over 70 MiB when loaded. Keep in mind this is regardless of whether it renders to 32x32 or 3000x3000).

And what's so great about interlacing, anyway? I've always hated progressive JPEGs and interlaced PNGs. If I have to wait a little longer for the next scanline, so be it, but I very much prefer it to getting it at 1/16 resolution.
Mar 21, 2010 at 4:58am
And what's so great about interlacing, anyway? I've always hated progressive JPEGs and interlaced PNGs.


Truth. Interlacing sucks.
Mar 21, 2010 at 5:40am
I didn't say interlacing was great. I just said that PNG had support for it.

Alpha channels, on the other hand, are great: http://upload.wikimedia.org/wikipedia/commons/a/a7/Hue_alpha.png
Mar 21, 2010 at 8:28am
closed account (z05DSL3A)
Disch wrote:
You can't really say this. I mean it's not fair to either one.

JPEG2000 is lossy
PNG is lossless


The JPEG2000 standard provides both lossless and lossy compression in a single compression architecture.
Mar 21, 2010 at 6:01pm
Interlacing is a Good Thing.

The rationale for interlacing is very straight-forward and reasonable. The PNG specification itself gives a very good explanation that is worth reading again.
Mar 21, 2010 at 6:22pm
By the way, my reasoning as to why SVG files shouldn't be compressed is because they're plain-text. If you compressed them, the best thing (IMO) about them (that they're human-readable and human-writable) would be gone.

@JPEG,
Uhhh, no.

As for raw BMP; I was going to mention it but I forgot. I think it's good because it's simple and it has alpha-channelling; but raw bitmaps are also very large. I have eight small PNG images in a folder and together, they are 2.8 kiB in size. As raw bitmaps, they total 916.8 kiB and as JPEGs, they total 9.2 kiB and the quality is horrible.
Mar 21, 2010 at 7:25pm
they're human-readable and human-writable
Yeah, totally.
<path
style="fill:#ee988b;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
d="M 4451.6667,397.86221 C 4441.0601,398.80501 4429.8333,390.52881 4429.8333,390.52881 L 4448.1667,381.86221 L 4503.2027,318.31741 C 4506.3727,314.56071 4506.0418,310.80401 4503.2449,307.04731 L 4494.7174,294.15791 L 4492.3604,291.91871 L 4485.7607,291.09381 L 4476.6862,293.92221 L 4488.5892,280.95861 C 4489.8856,279.58861 4490.898,278.04111 4490.9462,275.89101 L 4489.1784,255.85631 L 4485.525,251.96721 L 4477.1576,250.67081 L 4465.3725,252.32081 C 4465.3725,252.32081 4457.2408,259.86321 4457.3586,259.86321 C 4457.4765,259.86321 4450.0518,271.64831 4450.0518,271.64831 L 4431.9028,296.63281 L 4421.7676,309.24291 C 4421.7676,309.24291 4413.8715,317.84601 4413.6358,317.84601 C 4413.4001,317.84601 4407.5076,325.97771 4407.5076,325.97771 L 4405.622,330.92751 L 4404.9149,335.99511 L 4408.2147,340.35561 L 4413.9894,342.35901 C 4413.9894,342.35901 4456.5337,320.55661 4456.4158,320.55661 C 4456.298,320.55661 4426.953,351.08001 4426.953,351.08001 L 4415.5215,362.04021 L 4409.3932,368.16841 L 4407.2719,373.00031 L 4408.3325,379.95351 L 4409.0397,382.89981 L 4394.8975,383.25341 L 4391.2441,369.46481 L 4386.0587,355.79401 L 4377.5734,340.47341 L 4359.66,306.29661 L 4376.8663,310.06781 C 4381.1089,310.59811 4384.2909,308.35901 4384.2909,308.41791 C 4384.2909,308.47681 4426.8352,268.11281 4426.8352,268.11281 C 4426.8352,268.11281 4432.9634,252.55651 4432.9634,252.32081 C 4432.9634,252.08511 4433.6901,239.55891 4433.6901,239.55891 L 4431.4836,231.21811 L 4432.7277,229.69331 C 4445.4556,244.77821 4440.9773,261.86671 4440.9773,261.86671 C 4448.2841,253.85281 4456.7694,248.54951 4456.7694,248.54951 L 4469.4973,240.06421 L 4483.0502,233.46461 C 4485.7779,232.36061 4487.0782,230.36451 4487.2928,227.68991 C 4487.2928,227.68991 4485.525,210.13011 4485.525,210.24791 C 4485.525,210.36581 4493.0675,218.96891 4493.0675,218.96891 L 4496.7209,225.92211 L 4503.2027,245.01401 L 4509.8024,258.44901 L 4513.1022,271.17691 L 4513.1022,281.78351 L 4524.1802,294.74721 L 4531.0156,306.06091 L 4531.0156,317.84601 L 4531.487,322.79581 L 4522.5303,322.79571 L 4513.5736,328.21691 L 4467.3759,376.77161 L 4456.298,385.72821 C 4456.298,385.72821 4452.0553,392.09221 4452.0553,392.09221 C 4451.8721,394.24461 4454.2509,397.63091 4451.6667,397.86221 z"
id="path3269"
sodipodi:nodetypes="cccccccccccccccscccscccccsccccccccccccscsccccccccscccccccccccccccc" />
Last edited on Mar 21, 2010 at 7:26pm
Mar 22, 2010 at 12:51am
I assumed that because they were XML they would be more... sensical. My mistake.
Mar 22, 2010 at 2:24am
What's wrong with JPEG?

It is well-thought out and well-designed. It also provides a lot of flexibility when compressing.

(Just because some people produce horribly compressed JPEGs is not a valid argument against the format. For that matter, bad BMPs aren't an argument against the format, only against the person who created the image.)


RAW, BMP, and TGA are all relatively uncompressed formats. They are very friendly for intermediate storage and simple readers.
Pages: 12