Is it possible to modify a .jpg's bits, and not lose those changes to compression?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manontheedge
    New Member
    • Oct 2006
    • 175

    Is it possible to modify a .jpg's bits, and not lose those changes to compression?

    I'm able to read in a .jpg, alter pixel values, and save it again, as a .jpg, but the image gets compressed when saved. So when I read it back in, the values are not what I set them at, because of the compression when being saved, and I need the bits, every one of them.

    What I want is to be able to change individual bits inside pixels and save those changes, so that I can read the bit values back in. This works fine with bitmaps, but with jpeg's, is it even possible???
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I don't know the answer to that question, but if you think about it, what's happening makes sense. When you load a jpeg into memory, it's not really a jpeg anymore, it's an in-memory image. When you save it back out, you're then saving it as a jpeg, which is a compressed format. I don't think you can escape this.

    That being said, do you have to use a jpeg file? There are other options... specifically PNG files, which I find to be a much more robust format. It's still compressed, but it's lossless compression in that it compresses groups of similar data together, kind of like a ZIP file. It also has the advantage over a jpeg of supporting RGBA for per-pixel transparency.

    Comment

    • manontheedge
      New Member
      • Oct 2006
      • 175

      #3
      Well, what I'm working on, it's just something I was playing around with, doing some message hiding inside images. I've achieved this with bitmaps, but wanted to do it with jpeg files simply because they're so commonly used, and realised the compression issue, and now am just wondering if there is a way around it somehow.

      I actually discovered "EncoderParamet er" which you can use to compress LESS, but not avoid it entirely.

      Another thing I tried was converting a bitmap to a jpeg, and then working with the compressed jpeg to start with, but still didn't work how I hoped.

      Anyway, thanks for the reply, I appreciate the help and interest.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        When you're saying message hiding, do you mean you're trying to insert something into the image that's not immediately obvious, but when you compress it you can see the differences?

        If that's the case, yea I'm not sure what you'd do. The compression is built right into the format... you can't really control what the final RGB value would be since that would potentially defeat the purpose of the compression.

        Now, you said you want to support jpeg because it's a common format, and that's fine... is there any reason your output format has to be the same? Why can't you read in a jpeg (or any type) and output a PNG?

        Sorry I'm not able to be much help here :(

        Comment

        Working...