Is there a location inside the .jpg or .png where I can put an arbitrary 32-bit value method for embedding a 32-bit value inside that will not be visible in the image (but would change the hash of the image file.)
CodePudding user response:
Updated Answer
You can do that by adding a comment. If you want a technique that works with both JPEG and PNG and doesn't recompress your image data, I would suggest exiftool
.
You can add a comment like this to JPEG or PNG:
exiftool -Comment=32768 a.jpg
exiftool -Comment=32768 a.png
You can retrieve the comment along with all other information using:
exiftool a.jpg
Or, you can get just the comment and its value with:
exiftool -Comment a.jpg
Comment : 32768
Or, if parsing in a shell script, you can get the unadorned values like this:
exiftool -Comment -s -s -s a.jpg
32768
Original Answer
You can put a number or comment in a file with jhead
like this:
jhead -cl "32768" a.jpg
Modified: a.jpg
Then read it back, with jhead:
jhead a.jpg
File name : a.jpg
File size : 49732 bytes
...
...
Comment : 32768 <--- HERE IT IS