Joshua Stream Pre
  1. #1

    Subjecting a JPEG Image to Successive Compression Steps

    Greetings,

    I've seen a few discussions on JPEG Quality, but can't find (here, or elsewhere on the interwebs - at least not without analyzing the compression algorithm directly) an answer to the question implied on the Subject line. To wit:

    Let's say we have an uncompressed image, I, that we save as a JPEG with a Quality Factor of 60%. We'll call that compressed image, I60.

    Now, let's say that we take the same, original, uncompressed image and save it as a JPEG with a Q of 70%, and we call that image, I70. Then, let's say we take that 70% JPEG and save it, again, only now with a Q of 60%... We'll call it, I7060.

    Here's the question: Is the perceived Quality of I60 the same as the perceived Quality of I7060?

    Experimentally, I can say that the sizes of the resulting files are... similar. But, at least in the experiment that I performed, the file size of I7060 was actually slightly larger than the file size of I60.

    However, subjectively, I already have a hard time distinguishing between I and I60, so it's not likely that I'll be able to make a judgment about I60 vs. I7060.

    Hopefully, someone with direct familiarity with the compression algorithm can make a pronouncement on this from the theoretical perspective.

    So, what's the point? Well, I have a raft of images that were each assembled from a couple of uncompressed components, and then saved at 70% compression. They should have been saved at 60% compression. Unfortunately, although I have the original uncompressed constituents of each final product, I didn't save the intermediate, uncompressed, assemblies.

    Hence, my question. I just want to know whether I can get the same effective result by re-saving those JPEGs at the higher compression ratio, or am I actually compressing the original image to "60% of the 70%" (i.e. a Q factor of 42% - Hey... whaddya know, I finally have an answer of 42, and I barely know what the question is... Douglas Adams would be proud.)

    Thanks!

    - s.west

    p.s. Sorry for the long-winded post (I'm sure you're used to it from me by now), but I was trying to leave no aspect of the question open to confusion.

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    12,345
    Blog Entries
    9
    Interesting question, and though I think I can make a reasonable guess, I don't know. So, instead here are some references you might find interesting;

    https://www.webdesignerdepot.com/201...ffect-problem/
    However, lossy image formats, such as JPEG, can behave like photocopiers. If you simply copy a JPEG file, nothing changes. But if you open a JPEG file in an image editor and then save it, you will get a different JPEG file. Some information can be lost in the process, and compression artifacts will start to accumulate.
    So if you take a JPEG image that was saved with a quality of 70, then re-saving it with a quality of 90 will, of course, not make the image look any better. In fact, it will even be worse. Every additional JPEG encoding will introduce additional loss, even if it is done at a higher quality setting than the original JPEG.
    To make those numbers smaller, you divide them by some number—called a quantization constant—in the encoder, and then multiply it again by that same number in the decoder. The larger this quantization constant, the smaller the encoded values will become. But the image becomes more lossy because we’re rounding everything to integers here
    This one is I think what's really important for you;
    This also explains why re-saving a JPEG file at a higher quality setting than the original is always a bad idea: you’ll get a larger file with more loss than if you would re-save it at the exact same quality setting
    the generation count has a larger impact on the image quality than the actual quality settings you use.
    You might also like this discussion;
    https://photo.stackexchange.com/ques...ecompressed-mu
    I did not pull any quotes out of it since I don't know how verifiable any of them are.

    And if you really want to understand JPEG compression, their is this; https://www.ece.ucdavis.edu/cerl/rel...g/compression/
    I have not read it yet.

  3. #3
    Hello, swest!

    Quote Originally Posted by swest View Post
    Here's the question: Is the perceived Quality of I60 the same as the perceived Quality of I7060?

    No, if you open a JPG that was saved at 70% compression quality and then save it to 60% compression quality, you now have 60% of the 70%, which is 42% of the original uncompressed image (but it's still only 60% compressed of the source file which was 70% compressed previously). It's not going to be the same as opening the original uncompressed image and saving it at 42% because of the way JPG compresses the image. It may look the same, I've never tested or run the math, but my guess would be it likely isn't. In fact I would guess that compressing a compressed image will produce a noticably worse image than doing an eqivalent high compression on an uncompressed image since the first time compression runs is on uncompressed data, and the second time you compress something compressed. Keep in mind jPG compression is lossy, it throws away image information to achieve such low file sizes (it blurs or smooths neighbouring pixels into blocks, making them all the same colour), so trying to smooth already smoothed data will give you different results in the file (I think if you did it enough times you'd end up with an image where every pixel is the same colour).

    Personally, I hate image compression artefacts so almost always use PNG at the expensive of my players taking longer to download images. So far it hasn't caused any issues. But I just hate seeing images with text that has JPG compression artefacts, it gives me a headache!

    Hope that makes sense.

    Happy gaming!

    Kelly

  4. #4
    Thanks, so much, for the time spent replying on this subject.

    Following those comments I did something that I should have done before, because I knew that I had seen analysis reports on JPEGs before, and I knew that they included 'Quality' numbers and Quantization Tables... In other words, I think this means that the JPEG knows its own 'Quality'. Anyway, I have such an analysis utility at hand now, and I have to re-run my experiments. When I have done that, I'll post some additional empirical results. Also, I think I should run compressions with more difference than 70% followed by 60%. I'll think on that.

    Also, the reminder that JPEG is a lossy algorithm wasn't lost on me. But, I think the fact that a given image knows its own 'Quality' makes a difference.

    Thanks, again... and more later.

    - s.west

  5. #5
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    22,141
    Blog Entries
    1
    The results of that process will vary from image to image.
    Are the 70% images too big? If not use those. If they are do a single further compresssion and experiment with the levels until you have one that satisfies the look and size parameters you are after.
    Additionally changing subsampling to 4:2:0 or chroma quartering will save additional size with less visible artefacts.

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  6. #6
    Quote Originally Posted by damned View Post
    The results of that process will vary from image to image.
    Are the 70% images too big? If not use those. If they are do a single further compresssion and experiment with the levels until you have one that satisfies the look and size parameters you are after.
    Additionally changing subsampling to 4:2:0 or chroma quartering will save additional size with less visible artefacts.
    The fact of the matter is that the 70% images are probably fine.

    This all relates to the submission standards for conversions of the various publishers' (Paizo, Wizards, etc.) PDFs to the Fantasy Grounds store. The guidelines call for 60% JPEG Quality settings (to go along with maximum pixel dimensions of 1000x700.) As I mentioned in my original post, I had already used 70% before I found out about the actual guidelines, and, since I didn't still have access to the intermediate images, I was just trying to save the work of redoing them all from scratch.

    Now, to come completely clean on this, I made a design decision a little while after I made the original post that is going to require me to re-do all those images anyway... So, the question has largely been rendered moot.

    Needless to say, I don't want to come off as completely disingenuous. The reason that I'm still nattering on about this is because, eventually, it's going to come up again, and I'd like to think that I had found the correct answer when it does.

    Thanks for the additional guidance.

    - s.west

    p.s. Also, thanks for the reminder that there are other knobs to twist, as far as the file size is concerned. I'll be sure to keep those in mind from here on out.

  7. #7
    NotRussellCrowe nailed it.

    JPG is a Lossy fileformat, and terrible as a rule. Even if you set saves to 100% every single time you load and save an image you will decrease the quality. It is especially noticeable with text in an image, it will quickly become unusable.

    While you are working on an image save it in the programme's native format - ie .psp .ps etc.

    If you can't do that then save it as .tiff or .png NOTE - tiff's are huge because they are LOSSLESS.

    Anything with text use tiff or png. Anything with transparency use png.

    Once you have everything finished if you absolutely have to have it as .jpg and not as .png then save it as jpg then with the quality as high as you can get it while keeping the file size down. Consider your dpi resolution and also the number of colours an image has. Is it a monochrome image? If so you don't need to save it as 24bit!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SWADE Playlist

Log in

Log in