File sizes, can anybody explain

Discussion in 'Digital Photography' started by Biker2 \(Threadstopper\), Sep 6, 2005.

  1. OK, so I open a JPEG which has come straight from my camera a Panasonic
    DMC-LC1

    MS Explorer reports that the original file size is 1920 x 2560 = 3.59 MB

    I open the file in PhotoShop and adjust levels, saturation and then sharpen
    it a bit. I then save it as a copy and select 'Quality 12 Maximum ' when
    prompted.

    How is it that the file size is now 6.06 MB and where has the extra
    information come from ?

    Also, if I save the file as a TIFF, the file size increases to 14 MB !

    I am confused....

    Steve
    --
     
    Biker2 \(Threadstopper\), Sep 6, 2005
    #1
    1. Advertisements

  2. Biker2 \(Threadstopper\)

    bugbear Guest

    If you saved it as "FITS" it would be enormous.

    Try googling for file formats and compression.

    BugBear
     
    bugbear, Sep 6, 2005
    #2
    1. Advertisements

  3. Biker2 \(Threadstopper\)

    Justin Thyme Guest

    JPG compression is what is known as a "lossy" compression method. This means
    that it throws away some of the information in the photo when it saves it,
    the idea being that the extra detail won't normally be noticed. For example
    if JPG was a method of compressing words, JPG compression of "Good Morning"
    might come out as "Gd Mrning" - we can still understand it, but there is
    less actual detail there. We can never really know if "Gd" is "Good" or
    "Gold" but our brain fills in the blanks and understands what is being said.
    When your camera took the photo, it took an image with slightly more than
    1920x2560 pixels - It processes the results from the sensor to come up with
    an image that is 1920x2560 pixels x 3 colours (1 byte per colour), or
    14,745,600 Bytes of information (14MB). It then converts that image
    information into a JPG image, by throwing away some of the information in
    the image. The bits it throws away are the bits that will have the least
    impact on the final picture - so for example it might throw away some of the
    sky. This squashing down will result in an image that contains a lot less
    information but will still look pretty darned good to all but the pickiest
    eyes. So 14MB has now become 3.59MB. When Photoshop opens an image, it
    internally processes the image as a bitmap, so that 3.59MB JPG file gets
    expanded out to create a 1920x2560 pixels x 3 colours image stored in
    memory. This 14MB of information will be slightly different to the original
    14MB that your camera captured, because photoshop has no way of knowing
    exactly what was in the bits that were thrown away, but it makes a pretty
    good guess. Now when you save this as a JPG with photoshop, it will again
    throw away some of the information. The quality level you choose determines
    how much it throws away. So at level 12, it hasn't thrown away as much as
    your camera originally did, so the file size is now about 6MB.

    If you save it as TIFF, no data is thrown away, it stores all of the bitmap
    information that photoshop has been using internally, thus you get a 14MB
    file, because there is 14MB of pixel data that it is using.

    You will probably find that a quality level of about 8-10 in photoshop will
    give a similar file size to the original, however this does not mean that it
    is saving the exact same data that the camera saved. The picture information
    it throws away could be the image data that photoshop created when it
    expanded the image out to full size, or it could be throwing away some of
    the real image data and keeping the made up data - there is no way of it or
    you knowing. So if you were to repeatedly open and save the file, it will
    progressively get worse, as less and less of the original image data will be
    preserved. For this reason if you are going to be doing progressive editing
    of a photo, you should save it as a TIFF file at intermediate steps. JPG is
    ok when you have finished any editing you are likely to do and have come up
    with a version you will either print or display. Many will recommend that
    JPG not be used at all, but I think this is overkill. Just don't use JPG if
    you are going to be repeatedly open->edit->save on a file.
    The actual methodology of JPG storage does vary a little from what I
    described, and it is much more complex, but the above should give you some
    understanding of how it works.
     
    Justin Thyme, Sep 6, 2005
    #3
  4. Biker2 \(Threadstopper\)

    Chris Brown Guest

    JPEG is so-called lossy compression, it doesn't store exactly what is in the
    image. The easiest way to see this is when someone uses a JPEG to "compress"
    line art or text on a webpage - this is silly for two reasons. Firstly, JPEG
    will tend to produce a much larger file for line art than GIF or PNG, and
    secondly, if you look at the image you will see strange halos around sharp
    edges, almost as if the lines are "evaporating". These are JPEG artifacts.

    When you load a JPEG into Photoshop, you extract the information from that
    JPEG, and it is now stored uncompressed in your computer's memory, complete
    with all those artifacts, which are now part of the image. When you save it
    out again, you are askign Photoshop to compress what's left of your image,
    as well as those JPEG artifacts, and it will add its own. The image
    therefore gets bigger. If you keep doing it, it will add artifacts on top of
    the new artifacts, and the image will slowly look worse and worse, all the
    time getting bigger.

    Sharpening it makes this even worse - JPEG was designed for photographic
    images, and doesn't handle lots of harsh transitions very well (this is why
    it sucks for text and line-art). When you sharpen the image, you put in lots
    of sharp edges which take up more space to store in JPEG, and you also
    sharpen the JPEG artifacts that were there before.

    If you're going to habitually sharepn the images which come from your
    camera, you probably don't want to have your camera write JPEGs. JPEG is a
    format which is designed for storing images for display, not for processing.
    For processing, you want the image to be free of those nasty JPEG artifacts,
    for which TIFF or your camera's raw format should suffice.

    Note that turning a JPEG from the camera into a TIFF won't help - the damage
    to the image has already been done by then.
     
    Chris Brown, Sep 6, 2005
    #4
  5. Biker2 \(Threadstopper\)

    Jim Townsend Guest

    No.. Pixels and bytes are completely different things. They start
    with the prefix 'Mega' which means million.. That's the ONLY thing they
    have in common.

    If you multiply 1920 pixels x 2560 pixels you get 4.9 Megapixels
    In other words, you have a 5 megapixel camera.
    The TIFF file represents the ACTUAL memory your image requires.

    There are a minimum number primary colors required to make up the
    range of color we see. JPEG uses RGB which consists of a RED, GREEN
    and BLUE component. That's three colors.

    The JPEG file system uses one byte to represent each color. So
    if you have three colors, you need three bytes to create a pixel.

    Your camera produces 4.9 Million pixels, so it requires

    3 Bytes x 4.9 Million pixels = 14.7 Million bytes or 14.7 Megabytes

    As others have mentioned, JPEG uses compression.. That's how the
    file gets shrunk down to the 3 megabyte range.

    JPEG saves disk space (or memory card space) by using a mathematical
    formula to compress the file down to a smaller size. That's why your
    camera produces JPEG images that are 3.5 Megabytes instead of 14
    megabytes.

    Imagine if there were no compression.. You'd have to buy a lot more
    memory cards to hold the same amount of images.

    Note that JPEG only saves disk or memory card space. when you view
    the images they MUST be uncompressed back to their original 14 megabytes.

    When you edit the image, it is also uncompressed back to 14 megabytes.
    This is why you get a 14 megabyte image when you save as TIFF.. It gets
    saved as is and doesn't get compressed.

    JPEG has different levels of compression. You can do a little or a lot.

    The 3.5 Meg image from the camera was uncompressed back to it's original
    14 megabytes when you opened it in your editing program.

    When you saved this 14 megabyte file again, you didn't compress it at the
    same level as your camera did, so it was shrunk to 6 megabytes rather than
    3.5 megabytes.
     
    Jim Townsend, Sep 6, 2005
    #5
  6. Biker2 \(Threadstopper\)

    Jim Guest

    You math is a bit off. My calculator shows that 1920x2560 is 4.91
    Megapixels (not MB).
    Since there are three bytes per pixel when you are use 8 bits per channel,
    the size is three times the number of megapixels. Using quality = 12 causes
    the program to discard enough information to reduce the file size. There is
    no "extra information" here.
    As it should. Three bytes per pixels means that the uncompressed image
    requires almost 15 MB.
    You are not alone in that respect.
    Jim
     
    Jim, Sep 6, 2005
    #6
  7. I am using XP and in the bottom right hand corner of explorer it definately
    says 3.59 'MB'

    Steve......

    (not so confused now thanks to you and the other contributors)
    --
     
    Biker2 \(Threadstopper\), Sep 6, 2005
    #7
  8. Biker2 \(Threadstopper\)

    Bill DeWitt Guest

    Biker2 (Threadstopper) mentioned in passing :
    This seems to be a confusion of pixel count and file size. Multiplying
    pixels across by pixels down gives you the number of pixels, the bottom
    right hand corner gives you the "MB" (megabytes) of disc space used to store
    the file. Two different things. Depending on color depth (for instance), the
    file size is different for two equally sized images.

    Here is a pretend representation of a 4 pixel image file with 8 bit color
    10101010
    11001100
    11011011
    10010010

    There are 32 characters, takes up, lets pretend, 32 bytes.

    Here is a (pretend) 16 bit image the same pixel size.
    1010101010101010
    1100110011001100
    1101101101101101
    1001001001001001

    64 characters, 64 (pretend) bytes on the disk, but still only four pixels.
     
    Bill DeWitt, Sep 6, 2005
    #8
  9. Uhm ... 8 bits is one byte and you just represented 4 bytes in the above
    example.
    This is eight bytes.
     
    Thomas T. Veldhouse, Sep 6, 2005
    #9
  10. Biker2 \(Threadstopper\)

    Jim Guest

    That is the file size in megabytes. Explorer knows nothing about pixels,
    hence you cannot determine the number of pixels by merely looking at the
    file size (especially of a jpg).
    For example, I have a shot of the moon which I took with my D70. In
    Photoshop, the image size is shown as 2000 x 3009 pixels (that is 6
    megapixels) and 17.1 MB. However, explorer reports the size of the jpg as
    256KB. As the moon requires only a small part of the image, even low
    compression to jpg results in a small file size. I was just trying to see
    if I could get a reasonable shot at all else I would have saved it as a
    Tiff.
    Jim
     
    Jim, Sep 6, 2005
    #10
  11. Biker2 \(Threadstopper\)

    Bill DeWitt Guest

    Thomas T. Veldhouse mentioned in passing :
    For the sake of example, I used a clearly and redundantly marked
    "pretend" representation with "pretend" bytes. If you want a technical
    discussion, your local community college will have classes available for a
    fee. They will be called "Reading for Comprehension 101" or "Introduction to
    Not Taking Yourself So Seriously"...
     
    Bill DeWitt, Sep 6, 2005
    #11
  12. What were you pretending? That 8 bits equals 8 bytes? Yes, that is
    indeed what you were pretending. I was offering constructive criticism,
    but you inability to take it suggests you don't want to admit the error.

    What would be the purpose of pretending that bits are bytes?
     
    Thomas T. Veldhouse, Sep 6, 2005
    #12
  13. Biker2 \(Threadstopper\)

    ASAAR Guest

    That's the problem with you and others who are mired in reality
    based thinking. BD has no need to waste time with little "real"
    bytes when larger "pretend" bytes can show so much more.
     
    ASAAR, Sep 6, 2005
    #13
  14. Biker2 \(Threadstopper\)

    Bill Funk Guest

    The example you gave did represent 4 bytes; "pretending" it is 32
    bytes is very confusing.
    If I were to use that kind of "pretending" in any class, I'd certainly
    hear about it.
     
    Bill Funk, Sep 6, 2005
    #14
  15. Biker2 \(Threadstopper\)

    Bob Guest

    The first thing - these 2 numbers have nothing to do with each other!

    One is dimensions in pixels, the other is file size in bytes.

    It's just telling you that the photo is 1920x2560 in resolution size, and the
    file is 3.59 mb in size... it is a compressed file as well...

    JPEG stands for Japan or Joint (I forget!!) Photo Experts Group and they're the
    guys who invented the special compression techniques used for photos.

    Now, 1920 x 2560 = 4,915,200

    See the discrepancy? This is the PIXEL count.

    Now to make things more confusing, cameras make 32bit files, not 8bit, and a
    byte is ALLWAYS 8 bits! However, computers use 24 bit files for pictures, 8 for
    each of 3 colour's, so there is a lot of bit jiggling going on!

    Some cameras use 10 bits instead of 8 for each color, but your computer will
    adjust this to 8 bits so it fits into a byte.

    Usually we use 24bit files, which is 3 x 8 bits, so your 1920 x 2560 = 4,915,200
    x 3 = 14,745,600 bytes in total!

    Most picture files are compressed, so there is NO WAY to tell how many bytes the
    actual picture file will have.
    This is JPEG, right? You have a choice of compression amount.
    Re-sampling of data... this is a compressed file, all bets are off!
    This is the uncompressed version.
    We all are - don't give up!
     
    Bob, Sep 7, 2005
    #15
  16. Biker2 \(Threadstopper\)

    Greg N. Guest

    Justin Thyme wrote:

    Nice writeup! It deserves some nitpicking nonetheless:
    Decoding a jpeg does not involve any guesswork. The decoding algorithm
    renders exactly what's in the jpeg, no less, no more. I don't think a
    jpeg contains any information whether any given pixel is "true" or
    "approximated" or entirely wrong, as in an artifact.
    more correct would be: "... could be the data that was created when the
    image was compressed previously...".
     
    Greg N., Sep 8, 2005
    #16
  17. The file size when saving to JPEG depends on the "quality" setting
    in Photoshop. You can lower this to get a file size similar to
    the original file.
    Photoshop does not know the difference between information
    and noise. Shooting in JPG introduces noise in the form of
    JPEG artefacts. At the 12 "quality" setting, Photoshop uses
    extra bytes to faithfully preserves all the original
    JPEG artefacts your camera creates when compressing the image.

    Unfortunately, Photoshop will also add new JPEG artefacts when
    you save in JPEG. The "quality" setting mainly controls what
    new artefacts are created - at setting 12, there will be very
    little /further/ degradation, at setting 1, there will be
    extensive damage.

    To make a long story short: Every time a file is re-saved in JPG
    after editing, JPG-damage accumulates. If you edit your images, you
    shouldn't shoot in JPEG, but in RAW. You should also use a non-lossy
    format, such as TIFF or PSD (Photoshop's own format), for intermediate
    saves. Only save to JPG for uses that require JPG (i.e. putting
    images up on the web or sending to a consumer lab for printing).
    That is what it takes to save save /all/ RGB data from a 5 Mpx
    camera at 8 bits/channel.

    However, saving as TIFF makes little sense when you shoot in JPG,
    because the data lost through JPG-compression is gone and can not be
    restored. If you shoot in RAW, converting to TIFF for archival
    storage is fairly standard procedure.

    You may want to google for "raw" and "workflow" for more
    information.
     
    Gisle Hannemyr, Sep 9, 2005
    #17
  18. Make sure yiu know the difference between /file size/ and
    /pixel count/.

    Your image's /file size/ is 3.59 Megabytes (MB).
    But its /pixel count/ is 4.91 Megapixels (Mpx).

    /File size/ is measure of much space you need to store a file on
    your computer's hard disk. /Pixel count/ is a count of the number
    of picture elements (= pixels) that makes up the image.

    The file size of an /uncompressed/ image can be computed from
    the pixel count if you know how many channels and how many
    bits/channel is used. RGB images uses 3 channels and 8 or
    16 bits/channel. Assuming 8 bits (= 1 byte) per channel,
    we'll find that an image with a pixel count of 1920 by 2560
    requires 1920 x 2560 (pixels) x 3 (channels) x 1 (byte) =
    14 745 600 bytes or 14.7 Megabytes (Mb) of storage.

    Now, the file size explorer reports is a lot less than that
    (i.e. 3.59 Mb or 24 % of the original size), so as you can
    see a JPG file is very compressed compared to the full size
    image.

    If you shoot RAW, you'll find that the RAW file is less than
    14.7 Mb too. This is because the RAW file is compressed too.
    But the compression of the RAW-file is different from the
    compression of JPG. RAW-files uses lossless compression,
    which means that can take have a smaller file size without
    losing information.
     
    Gisle Hannemyr, Sep 9, 2005
    #18
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.