1

Im currently working on a project where I want to deliberately corrupt images. Iv been trying to do research of to how to do this for a few weeks now and just keep finding my self going in circles. I know that bad SD cards, copy processors and bad connectors are responsible for this to happen however what I'm asking is why and how dose this happen? Is there a way I can I manually open up the image file and change its characters?

Thank you :)

closed as unclear what you're asking by scottbb, Itai, Olivier, Philip Kendall, mattdm Jul 6 '17 at 19:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    I'm not voting down as a valid question but I don't think it's really related to photography? Wouldn't this be better placed for stackoverflow? – Crazy Dino Jul 1 '17 at 14:02
  • 2
    I voted to close this as "unclear what you're asking", but after re-reading, it appears clear to me that this is off-topic for this site. Stack Overflow might be the place for it, but I'd suggest Reverse Engineering as a better fit. – scottbb Jul 1 '17 at 14:12
  • Are you trying to corrupt the images intelligently (i.e., context-aware of the image file format to corrupt certain meaningful pieces of data), or are you just trying to fuzz the files (i.e., randomly change bytes)? – scottbb Jul 1 '17 at 14:15
4

Try a web search for "Hex editor". There are several around, including some free ones. They can display the values of the bytes making up the file as (ususally) hexadecimal (base 16) values - each 8 bit byte shows as 2 hexadecimal digits. Some may also allow you to display the values as octal (base 8) or binary (base 2). As with most editors, you can search for things (usually either as normal text, or for byte values) and add/remove/change things.

Typically, what happens when a file is corrupted is that either some part of the file is lost while copying, or extra garbage inserted, or that some of the data values are changed - or some or part of the file is later overwritten by something else.

depending on the image format, changing the data may either change the colour of a pixel (raw pixel values), mess up a line (run length coded values), or make the image unloadable (some header fields or compression schemes).

For most compression schemes, the loading software may be able to tell that there's a problem if the change affects any of the spatial (run length) information, but may not be able to tell if the change only affects colour information - if it's expecting a 1000 pixel long line, and the data decompresses to 1020 or 980, then that's fairly obvious if it's checking, but having a red pixel instead of a green one isn't noticeable. Similarly, if the change trashes essential header information (like the size of the image) then there will be problems.

Depending on what you're trying to do with the corrupted images, you may need to do more research on the image formats involved.

Edit: For anyone who is wondering why the editors show the byte values as hex, octal, or binary values instead of a normal decimal (base 10) number - it's because in a lot of data formats, different parts of the bytes can be used for different things - for example, you might use 2 bits of the 8 bits in a byte to represent 4 possible different colours, and the other 6 to represent a repeat count (0-63, or 1-64 if you add one to the number), and with the hex/octal/binary display it's easier to split the numbers up and work out what the bit pattern is - each digit represents a separate set of bits, unlike decimal, where things get mixed together:

7A (hex - uses digits 0123456789ABCDEF) =

0111 1010 (binary, spaced to show hex relationship - uses digits 0 1) =

01 111 010 (binary, spaced to show octal relationship) =

172 (octal - uses digits 01234567) =

132 decimal, which has no obvious relation to the binary version.

  • 1
    If you want to send up with a corrupt image that will displays you can choose a format accordingly (ppm, bmp) – Chris H Jul 1 '17 at 21:28

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