Why does a scan of a simple text document result in such a large file?
Hi, everyone.
Leo Notenboom here for askleo.com.
Here's the question.
"I scanned a copy of my W2 form
and tried to email it to someone, but I was told the file was too big.
25 megabytes.
How does a simple text document acquire such huge volume?"
Well, it actually is a pretty simple situation.
What you're doing when you scan a document is you're taking a picture of it.
Not unlike taking your camera and taking
a picture of something at relatively high resolution.
When you take a picture, you're creating an image file.
It doesn't understand what's in the image.
It just says here's a rectangular array of pixels with different color values
that represent whatever it was I was looking at when the picture was taken.
Scanners are exactly the same.
They're just optimized to take pictures of flat documents.
Let's take a quick look at why this is so dramatically different.
If we go to the article on which this
video is based, if you'll scroll down, you'll see that there is an example here:
text versus picture. You'll see that there are some text
and you can tell that it's text because you can select it one character at a time.
In fact, if we select all of them, you'll see that we've selected exactly
eight characters, which at its simplest would take eight
bytes to represent without any of the formatting or font information.
But just the eight characters of Ask space.
Leo Exclamation point actually represents the entire thing.
Now, down below is a picture of that text.
You can tell it's a picture, because if you select it, it selects all at once.
There's no way to select a piece of this text.
So this is a PNG file, and which means it's an image file.
A PNG is portable network graphics,
and it is 2431 bytes. Over 300 times the size of just the plain old text.
That's because it's a picture.
It can't make any assumptions about what's inside. It's a 133 by 40 Pixel image.
Now, there are at least three different ways to deal with the size, if you will,
of the resulting image of a scanned document.
The first one I'll talk about is called OCR or optical character recognition.
What that does.
It would take the picture of the document that you just created and actually use
intelligence to see what characters it can find in that document.
If the picture contains something that looks like an L, well, that's an L.
If it contains something that looks like an E.
Well, that's an E.
So in theory,
it could take that picture we have of Ask Leo Exclamation point and turn it
into the eight characters Ask Leo!
There are several problems with optical character recognition.
One is it's notoriously inaccurate.
It is highly, and I mean highly dependent
on the quality of the original document that it's being applied to.
It's not at all uncommon for optical
character recognition to get a character wrong.
Think about the difference you might see
between a lowercase L and the number one in so many different fonts.
OCR can't really make any assumptions, so it kind of has to make a choice.
It can try.
And some OCR is definitely better than others, but it's not always right.
Same thing is true if the image is out of focus or has a lot of noise
embedded in it, or struggles with that. There is good OCR there's bad OCR,
but OCR is, like I said, inherently somewhat error prone.
The other problem with OCR that you lose something.
For example, in the case of your W2
form, there's a good chance that most OCR would lose the layout or lose the lines or
lose any images that happened to be present in that form.
It would not look anything like the form you started with.
When OCR was finished.
You would have the text.
It just wouldn't look like the original document.
Option number two is what I'll call scan resolution.
When we scan a document,
we have a choice for how fine a scan we really want to make. When you scan it,
you can choose to say, I want you to scan this at 300 dots per inch.
That means that you will get very high
resolution detail of the characters that are on that page.
The downside, of course,
is that higher resolution means more dots, more dots means more data.
More data means a larger image file.
If I had to make a guess about
the problem, you came to me with, you're probably scanning at a fairly high
resolution because in all honesty, W2 generally isn't all that big.
So one of the things to try would be to see if your scanning software can be
configured to use a lower DPI. 75 is typically good for printed documents.
It matches that balance between being able
to see the document clearly visually and still have it not be too big.
The third option is image compression.
Now the PNG file that I showed you as
my Ask Leo example includes compression, but it is lossless compression,
which means that there is no assumption made about the data.
The data that when it is decompressed is identical to the data that was compressed.
Jpeg files have lossy compression.
That means that if you take an image and convert it to JPEG,
the result will not be bit for bit identical to the original.
What JPEG does is it says, I know this is an image.
I know this is a photograph.
That way I can make some assumptions based
on knowing how these things are viewed by human eyeballs.
In addition, JPEG has a quality control.
You can say save this JPEG at high quality or low quality.
There's lots of different places in between.
Once again, let's turn to the example
in the original article, you'll see that I have a scan here of a card.
This is a business sized novelty card.
The top image is saved with a JPEG quality
of very high, probably the top most quality available for JPEG images.
The image below is saved at a lower quality, and if you look carefully,
you can see that it just looks a little fuzzier.
There's things around the letters, there's just what they call potentially
artifacts that just make it look a little less clean than the original.
Is it good enough? That depends on what you're doing with it?
In the case of a W2 probably could be.
And the net result is that at a lower quality setting,
JPEG files can be significantly smaller than the higher quality equivalence.
The good news also is that JPEG files, typically because they use lossy
compression, are often, especially for images, smaller
than PNGs, so that's something else to play with.
Both choose your file format.
Be a PNG or Jpg.
And if you're using Jpg, adjust the quality setting when you save
the image to see if perhaps you can make it somewhat smaller.
I hope that was helpful.
Those are some ideas that commonly come up when you're scanning documents and they
end up being very, very huge depending on what you're scanning, be
at a document or a photograph or something else.
All of these are things that matter and you may want to set differently
depending on what it is you intend to do with the resulting scan.
For links related to this article for updates for comments and more, visit
askleo.com/6165
I'm Leo Notenboom.
This is askleo.com