GIF or JPG?

L

L.Jones

Why do some people use GIF image files over JPG , even when the image is a
still one and not animation?

Also, the psuedo element <img src="../../*.jpg"> loads current IE and NN
browsers with my images, but not OPERA. Instead, it shows the word 'IMAGE',
as if I have the pathname wrong. But it's right. What gives?

L.
 
K

Kurt Weber

L.Jones said:
Why do some people use GIF image files over JPG , even when the image is a
still one and not animation?

Also, the psuedo element <img src="../../*.jpg"> loads current IE and NN
browsers with my images, but not OPERA. Instead, it shows the word 'IMAGE',
as if I have the pathname wrong. But it's right. What gives?

It has to do with the compression algorithms.

GIF uses a lossless algorithm, so it is useful for simple line art and other
images that don't involve a significant degree of color variation.

JPEG, on the other hand, uses a lossy algorithm that, in effect, blends
several adjacent pixels into one, making it more useful for photographs,
complex 3-D images, etc. that have significant color variation and fine
detail that is not likely to be noticed when "smoothed over", so to speak.
 
K

Kurt Weber

Let me be a bit more detailed.

GIF uses the LZW compression algorithm, an algorithm which enables one to
produce a complete replica of the original data. To do this, the software
finds certain recurring bit patterns in the original data. For each pattern
it finds, it assigns it an identifier that is shorter than the data it
represents. Then, every time that particular pattern appears in the data,
it is replaced with that identifier. In the GIF file is a table listing the
identifiers and the patterns they replace so the reader can reconstruct the
original example.

As a somewhat contrived example, imagine that you are writing a paper on,
say, the Spanish Inquisition. You have a computer on which you can do all
the edits and revisions, but you don't have access to a printer or removable
storage, so you are forced to submit a handwritten copy. Since writing
things out by hand takes time, you decide to assign certain codes to certain
words that appear quite often in the text. For example, every instance of
"Torquemada" is assigned "A1", every instance of "ideology" is assigned
"A2", every instance of "the" is assigned A3, and so on. So the paper you
give to your professor is a sequence of codes that required much less
writing than writing out the entire thing would have been, and attached is a
table correlating each code to the word it represents. All your professor
has to do, then, is go through this table and replace each code with its
associated word, after which he is free to corner the market on red ink.

LZW (which GIF uses) is ideal, then, for simple line-art pictures because
such images are likely to contain several repeating patterns of data--for
example, a large plain white background with a regular area of green or
purple inside, perhaps with a sequence of red-purple-orange-blue-red
occurring several times as well. This doesn't work so well with photographs
which, by their very nature, generally do not have many repeating patterns
within. As a result, GIF would almost certainly not produce any significant
improvement in file size on a photograph (and in fact would probably be
larger than the original data because of the metadata overhead). Instead,
photographs are generally distributed in the JPEG format, which essentially
"smears" similar pixels in an area together to reduce the amount of data
necessary. While this would probably not have an adverse affect on the
types of images for which GIF is typically used, GIF generally produces
better compression ratios on simple images than JPEG does.
 
W

Webcastmaker

Why do some people use GIF image files over JPG , even when the image is a
still one and not animation?

Because different images are better displayed in one or the other.
 
S

Spartanicus

L.Jones said:
Also, the psuedo element <img src="../../*.jpg"> loads current IE and NN
browsers with my images, but not OPERA. Instead, it shows the word 'IMAGE',
as if I have the pathname wrong. But it's right.

No it's not, upload it and provide the url.

And img is not a "pseudo" element.
 
T

Toby Inkster

Kurt said:
As a somewhat contrived example, imagine that you are writing a paper on,
say, the Spanish Inquisition. [...] For example, every instance of
"Torquemada" is assigned "A1", every instance of "ideology" is assigned
"A2", every instance of "the" is assigned A3, and so on.

Actually, the concept you've just described is a substitutional compressor.
LZW is an algortithm for choosing the best words to include in the
dictionary when using such a compression method. To continue your analogy
LZW will tell you whether it's better to substitute A1 with "Torquemada"
or with "Madrid" (perhaps because "Torquemada" is longer, but "Madrid"
occurs more often in the text?)

There is a nice write up and example here:
http://computer.howstuffworks.com/file-compression.htm/printable

To further your analogy, JPEG compression is just like writing a 3-line
summary of the original paper on the Spanish Inquisition.
 
F

Frogleg

<snip/>

Man, are you on meth?

Actually, the first paragraph was a very neat explanation. I tried to
understand LZW for years, and could certainly have used this
clarification. Just stop reading after para #1. :)
 
K

Kurt Weber

Toby Inkster said:
Kurt said:
As a somewhat contrived example, imagine that you are writing a paper on,
say, the Spanish Inquisition. [...] For example, every instance of
"Torquemada" is assigned "A1", every instance of "ideology" is assigned
"A2", every instance of "the" is assigned A3, and so on.

Actually, the concept you've just described is a substitutional compressor.
LZW is an algortithm for choosing the best words to include in the
dictionary when using such a compression method. To continue your analogy
LZW will tell you whether it's better to substitute A1 with "Torquemada"
or with "Madrid" (perhaps because "Torquemada" is longer, but "Madrid"
occurs more often in the text?)

Yeah, I realized afterwards that LZW was simply a particular ALGORITHM for
using the concept, but by then my fingers were tired and I figured he'd get
the idea regardless :)
 
C

confused replies

patching the url from the uploaded jpg file into Opera,.then patching it
into a <img src="..."> element still does not allow Opera to open my jpg
files from my HTML (and CSS) code. Again, IE and NN both work. Same code.
Same pathname.

I re-installed Opera. No luck.

Does anyone else have this problem with Opera?
 
R

rf

confused replies wrote
patching the url from the uploaded jpg file into Opera,.then patching it
into a <img src="..."> element still does not allow Opera to open my jpg
files from my HTML (and CSS) code. Again, IE and NN both work. Same code.
Same pathname.

I re-installed Opera. No luck.

Does anyone else have this problem with Opera?

Without a URL I can't even *see* the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top