Modifying JPEG headers in C#

I'm trying to open a file to bytes, convert it to a string, modify some data (think Steganography) and convert the file back to bytes and save it as a jpeg. So far, everything I've tried has corrupted the file in converting it to a string. I've tried converting it to a 64-bit string, but of course that's a bit hard to modify the data in :P

Any suggestions on how I can do this properly, without corrupting my file?


I don't have this in C# but in PHP, but you can take a look and adaptate to C#.

This is my site where there's a tool to modify the EXIF data of a JPEG and build "magic pictures" which display something in the thumbnail which is not the real picture.

It opens the JPEG, slice its sectors, and build it back ignoring irrelevant sectors and placing my custom made EXIF header.

And this is the source of the PHP classes: (ExifMapper is incomplete)

You can study it and rebuild in C#, it is really simple to slice a JPEG as you will see.

Usage of this PHP class (only JpegMapper):

$jpg = new JpegMapper('picture.jpg');
$jpg->save_filtered('filtere picture.jpg'); // save removing irrelevant sectors

It is great to get any JPEG even smaller (sometimes a lot smaller).

Need Your Help

Creating and Storing Values in a Datatable Using Session Variable

c# datatable

I'm having a problem storing and displaying values from a datatable. My goal is to add a value to a datatable, reload the page, and then display the datatable with the added value and give the abil...

Extract hash tag from String

java extract

I want to extract any words immediately after the # character in a String, and store them in a String[] array.