Here is the original file that I will databend throughout this demo.
Currently this file is a jpg. Lets try to bend it as a jpg first.
First, I never want to operate on my original image, because it might break horribly.
cp mona_lisa.jpg ex-1.txt
. Notice that I changed the file extension to a text file.cp ex-1.txt ex-1.jpg
, but you could do this with the file manager too.I found JPGs easy to break, I got a lot of results that looked like this:
Being a little more strategic on what you are changing might help here.
Bitmaps are more forgiving filetype to edit. Let’s try one of those.
convert mona_lisa.jpg mona_lisa.bmp
cp mona_lisa.bmp ex-2.txt
cp ex-2.txt ex-2.bmp
Open the image file to preview your changes.
By working with the file as hex, we might get a better understanding of how a file type is structured. We can also be more surgical in our edits by working at the byte level. This would work with any image type, but I’m going to stick with bmps for now.
cp mona_lisa.bmp ex-3.bmp.hex
, notice I changed the file name and added a .hex
extension.Now we see the hexadecimal representation of the file. Every two hex values represent one byte of data. i.e. af06
is one byte.
cp ex-3.bmp.hex ex-3.bmp
, here I’m making a copy, so I can keep editing or undo changes I don’t like.Open the image file to preview the results.
Sometimes small changes have big results. Here I think I edited something near the top.