If we open a PNG file in Windows Notepad and change it, the file becomes unusable. Why can’t we reverse the damage by changing the text back to its original state?

82 viewsOtherTechnology

If we open a PNG file in Windows Notepad and change it, the file becomes unusable. Why can’t we reverse the damage by changing the text back to its original state?

In: Technology

2 Answers

Anonymous 0 Comments

If you keep notepad open, and simply ctrl-z to undo the change, then you can.

However, when you open it in Notepad, Notepad doesn’t actually know what it’s trying to read, and the gibberish it spits out is the encoding method’s “best guess” (for want of a better explanation) of what it sees. It’s not a perfect 1:1 of the actual binary in the file. Therefore, if you find the same characters and put them back in manually afterwards, it’s once again not a 1:1 match to what was there beforehand. There may be some characters that didn’t get rendered that got deleted as well which you have no way of re-entering yourself.

Anonymous 0 Comments

Because Notepad is dumb. It is made to understand text files, and those don’t allow all byte combinations. When asked to save something it doesn’t understand, it may apply text formatting conventions, such as always following a carriage return command with a line feed command. In a PNG file, those same bytes mean different things, and now they’ve been scrambled. If you want to poke at any file without having it changed unexpectedly, use a hex editor. It’s made specifically for that purpose and doesn’t try to translate it into something it’s not.