Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Hi I'm sure there were a lot of similar questions asked, but after searching a lot I didn't find any post describing my situation.

I have some jpg files which have some colours wrong after a certain point and also every pixel is shifted to the left. I think this is because of some missing bytes at the point where it changes. I tried to edit the file with vi but it seems impossible to find out where the missing bytes are, also vi is very complicated to use. I also tried nano but it's not binary-safe.

This is one of the images in question:

enter image description here

So I want to ask you two questions:

  1. How can I repair such images in Linux?
  2. How could I safely open and edit the file in a binary text editor under Linux?

Edit: using hexedit I discovered that from position 0x27F000 to 0x27F403 there are only ones 0xff, and from 0x27F404 to 0x27FFFF there are only zeroes 0x00. This makes something like this:

    0027EFF0   F8 83 C3 E2  09 35 AF 13  44 6E C5 FD  C7 EF 23 E8  .....5..Dn....#.
    0027F000   FF FF FF FF  FF FF FF FF  FF FF FF FF  FF FF FF FF  ................
    0027F400   FF FF FF FF  00 00 00 00  00 00 00 00  00 00 00 00  ................
    0027FFF0   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
    00280000   8F 39 6E 47  4F 43 5F 36  7C 73 66 F1  0D AE AD AF  .9nGOC_6|sf.....

Changing these bytes with random numbers I was able to unshift the image, but there is still the colour problem.

Could someone point me to some documentation about jpeg encoding so I can figure out how to know where an 8x8 block ends.

I'm wondering why the positions are so precise (0x27F000 to 0x27FFFF), could this be a bug of my cam or the memory card I used?

share|improve this question
I had this happen once to a large set of images. I just ended up deleting them, a shame really. I'd be interested to know if you succeed in repairing these, you've got a tough job ahead of you. –  dtmland Jun 24 '13 at 20:16
Yes it is it's a shame, I'm trying to figure out how this jpeg files are encoded, it's just one 8x4000px line which I will have to delete. In this file there are exactly 4KB damaged in a file of 4.4MB It's less then 0.1%!!! –  Falk Jun 25 '13 at 14:23

1 Answer 1

2) How could I safely open and edit the file in a binary text editor under Linux?

Lots of great binary editors can be found here: http://stackoverflow.com/questions/839227/how-to-edit-binary-file-on-the-unix-systems

My personal favorites are vim with :%!xxd hack and hexedit

share|improve this answer
Ok, and something easier to use? like nano. –  Falk Jun 24 '13 at 14:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.