I simply take a picture by an ArduCAM Ov2640 and record the data on an SD card. When I don't change the SD card data, I can open it as a jpg picture.
My problem: I have to add a timestamp to the first line of the data while writing the data on the SD card. Later, when I use notepad to open the file and remove that Timestamp, the picture format gets corrupted.
Does anyone know how to add a Timestamp to SD card jpg data and remove it later without losing the jpg format?
Usually I would expect the date to be an attribute of the file's directory entry, not part of the file itself.
I expect that the problem though is that JPEG is a binary format and notepad isn't equipped to deal with it. Use something else, or write a little program to copy the JPEG component to a new file.
mebab:
I simply take a picture by an ArduCAM Ov2640 and record the data on an SD card. When I don't change the SD card data, I can open it as a jpg picture.
My problem: I have to add a timestamp to the first line of the data while writing the data on the SD card. Later, when I use notepad to open the file and remove that Timestamp, the picture format gets corrupted.
Does anyone know how to add a Timestamp to SD card jpg data and remove it later without losing the jpg format?
Thanks for any help!
You did not tell us that you tried to remove the time stamp and restore the proper JPEG formatted file. How does the restored JPEG file differ from the original JPEG file?
Paul
Paul_KD7HB:
You did not tell us that you tried to remove the time stamp and restore the proper JPEG formatted file. How does the restored JPEG file differ from the original JPEG file?
Paul
I believe that the file content after removing the Timestamp looks the same as the original one. However, when I play it, I receive the following error:
mebab:
I believe that the file content after removing the Timestamp looks the same as the original one. However, when I play it, I receive the following error:
We can't open this file.
Then it is not the same as the original. What code did you use to add the date and what code did you use to remove the date.
Paul
wildbill:
Usually I would expect the date to be an attribute of the file's directory entry, not part of the file itself.
I expect that the problem though is that JPEG is a binary format and notepad isn't equipped to deal with it. Use something else, or write a little program to copy the JPEG component to a new file.
Agree with you. It is also possible to make a text file from ArduCAM's taken photo and add a Timestamp. However, even after removing the Timestamp from the text file and changing the extension from '.txt' to '.jpg', I cannot retrieve the original photo. The problem is that as soon as you touch a '.jpg' file and save it by notepad or Wordpad etc., it is not the original one after you remove whatever you have already added!
Paul_KD7HB:
Then it is not the same as the original. What code did you use to add the date and what code did you use to remove the date.
Paul
This happens not only by code but also manually. Just take a jpeg file. Then add a letter and remove that letter. save it and try to open the file. You won't be able to open it!
I use either of the following codes to add the Timestamp in the first line of the photo data:
myFile.println(TStamp_MSG[5]);
or
myFile.write(TStamp_MSG[5], 16);
To remove the Timestamp, I just open the file manually by notepad. Then remove it and save it.
To muck around with files such as a JPEG, you need a proper HEX editor which is designed for such stuff and will not change the file data. I have not used one in many years and do not know of one to help you. But others do.
Paul_KD7HB:
To muck around with files such as a JPEG, you need a proper HEX editor which is designed for such stuff and will not change the file data. I have not used one in many years and do not know of one to help you. But others do.
Paul
Thanks, Paul!
Based on your comment, I tried using 'HxD' as a Hex editor. For working manually, it can solve problems with adding and removing items to a Jpeg file (opened by the Hex editor) which is great!
I will have to figure out how to apply your comment and deal with Photo data as mentioned in Arduino, SD card, Transmission, etc.