I am working on a writing a program that embeds data in a photo (steganography). This worked completely fine when I was using png lossless compression however I would like this to work in JPEG file format. Previously I would read in my image file and replace the last two bits in every color channel with a part of my message. Then I would compress it and output it. With lossy compression however I am assuming I cannot embed a message pre compression because without a doubt, the message would be unreadable.
My question is, do I need to embed the message post compression/encoding somewhere in the SOS YCbCr data? If not there then where must I store the message? Thank you in advance.
The best place to hide a message in JPEG is in the blocks that extend beyond the edge of the image (unless the image dimensions are multiples of 8).