JPEG lossless re-sizing?

Discussion in 'Digital Cameras' started by Bob & Anni, Dec 7, 2003.

  1. Bob & Anni

    Bob & Anni Guest

    I know it's possible to do JPEG lossless rotation and cropping but is it possible to do lossless re-sizing as well?
    Starting with large images (pixel count) I use jpegcrop to crop to the required composition but then I want to resize the resulting
    image to fit my web pages.
    Bob & Anni, Dec 7, 2003
    1. Advertisements

  2. Bob & Anni

    Bob & Anni Guest

    Thinking about this, it's probably only possible to do a lossless resize to 1/2 1/4 1/8 1/16th etc
    Just realised that it wouldn't help me anyway as I need to add a logo and sometimes adjust the contrast or colour, so that would
    probably mean recompressing anyway
    Interesting subject never the less
    Bob & Anni, Dec 7, 2003
    1. Advertisements

  3. Bob & Anni

    Andy Hewitt Guest

    Why not convert the image to a non compressed file format, such as TIFF
    or PICT, even the editor's own format (Photoshop has it's own file
    format for example). Ensure you start off the with minimal compression
    JPG file though.

    You can then edit and resize with minimal, or no, loss. Save as a JPG at
    the final stage.

    If you're making images for web pages, you need to keep size below
    640x480 anyway, and preferably keep the 4/3 ratio as well.
    Andy Hewitt, Dec 7, 2003
  4. Bob & Anni

    Trev Guest

    resize to 1/2 1/4 1/8 1/16th etc
    and sometimes adjust the contrast or colour, so that would
    I think you mean without too much of a loss. It is impossible to remove
    75% of the pixels with out a loss of 75%.
    On the other hand the jpeg compression of a 600 x 400 does not need to
    be high enough to cause bad artefacts when getting the file size down
    Trev, Dec 7, 2003
  5. Lossless downsizing is never possible, JPEG or not.

    Lossless upsizing is not possible with JPEG. JPEG is
    coded in 16x16 squares. Each such square is transformed
    from the spatial to the frequency plane and then the
    resulting frequency representation is compressed lossy.

    Roland Karlsson, Dec 7, 2003
  6. I know it's possible to do JPEG lossless rotation and cropping but is it
    possible to do lossless re-sizing as well?

    What does "lossless re-sizing" mean? Reducing the number of pixels while
    retaining the same number of pixels?
    Andrew Koenig, Dec 7, 2003
  7. Given that lossless cropping of JPEGs is also an oxymoron, but that
    most people understand the meaning (avoiding artefact introducing
    recompression), a bet would be that Bob & Anni wants to do the same
    for resized images.

    I wouldn't be too worried about the errors introduced by a complete
    recompression, if we're talking about resizing to a smaller image. The
    old JPEG artefacts would likely be rendered invisible by the resizing,
    so only new artefacts would be visible. Besides, for webuse I'd
    normally compress harder than for other use so a recompression would
    be worth considering even if it was possible to do without.
    Toke Eskildsen, Dec 7, 2003
  8. Bob & Anni

    Bob & Anni Guest

    At last, someone who understood what I meant by lossless - you pedantic lot :)
    I naturally thought everyone would understand that reducing the size in pixels would constitute an OBVIOUS "loss" but I was
    referring to artefacts and the overall effect this has on the overall quality.
    I'll try and be more precise next time, seems so many people are quick to jump in with smart comments.

    Thanks Andrew, yes as I said in my second post, it's probably not possible to do an arbitrary resizing without recompressing.
    I've always taken the jpegs from the camera (it only offers jpegs before anyone jumps in with a comment) and converted them to tiff
    before doing any work on them. Converting back to jpeg just prior to posting to the web.
    Bob & Anni, Dec 7, 2003
  9. Converting from a jpeg to tiff BEFORE working on an image buys you nothing.
    You can't INCREASE on the information content of the original jpeg.
    When you open a jpeg image in Photoshop, PS uncompresses the image to .psd format in much the same way that tiff would do. So you are
    always working on an uncompressed image file. Only when you SAVE the image does it make sense to convert to .tiff rather than .jpeg.
    SAVING in jpeg will apply another layer of compression on top of the original .jpeg degrading it somewhat . Having said that, however,
    I might add that you can SAVE in highest quality .jpeg compression quite a few times before the difference in quality is noticeable.
    Bob Williams
    Robert E. Williams, Dec 7, 2003
  10. Bob & Anni

    Bob & Anni Guest

    Thanks for clearing that up Robert, obviously I don't "convert" them as a separate job before working on them. I just do as you say,
    open them in an editing program and working on them before saving as tiff. Didn't think I would have to spell everything out, wish I
    hadn't started this now :-(
    I hope I didn't give the impression I was expecting to gain any information, that would be a stupid thing to expect.
    Bob & Anni, Dec 7, 2003
  11. You can do lossless cropping - if you crop according to a 16x16 grid.

    Roland Karlsson, Dec 7, 2003
  12. Bob & Anni

    Bob & Anni Guest

    Yes Ron, you can do cropping as long as you crop on the correct boundaries based on a 16x16 pixel grid.
    See this program jpegcrop.exe
    available at
    which got me thinking about resizing in the first place.
    Bob & Anni, Dec 7, 2003
  13. A "lossless resize" with JPEG is not directly possible.
    However, if you use Jpegcrop with the zoom feature, you see that an optimal
    JPEG decompression to N/8 size with all N=1...16 is possible. But you
    would incur further loss if you would compress the result again to JPEG.

    Therefore I think that the best solution for the future would be to
    make JPEG decoders (and encoders) more flexible by supporting different
    spatial resolution output directly (see and, so you could avoid recompression when resizing.

    There is also a generalization of the method for arbitrary rescaling,
    but with more computational effort and not yet implemented. I will look
    into this later.
    Guido Vollbeding, Dec 8, 2003
  14. (Samuel Paik) wrote in
    I am quite sure that it is not possible.

    Roland Karlsson, Dec 8, 2003
  15. What you can do is compressing a spatial image to JPEG in such a way that
    it gets upsized by factor 4 or 8 and can be decoded *losslessly* to the
    original image, if using my new methods (see
    for more details).

    Guido Vollbeding, Dec 9, 2003
  16. hehe ... sometimes someone implements the most strange things.
    Thx Guido for pointing this out. Looks like you have a fun time
    coding your djpeg/cjpeg thingies.

    Roland Karlsson, Dec 9, 2003
  17. This comes from the fact that these new resizing features are based
    on the most important discovery about fundamental DCT properties
    since introduction of JPEG. You can read something about it in a
    paper I wrote for a conference recently:

    Guido Vollbeding, Dec 10, 2003
    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.