-1

I ran into an issue when trying to extract file creation date via Python. I am using Python3.6 on 64bit Windows7.

I have a number of pictures (jpeg) that were taken [I should use "created" instead] in the past and uploaded to an on-line album on the same day. [Note: These JPEGs are not 'fresh' off the camera, some of them have been processed by other software and then "saved as"; Some of them are actually cellphone screenshots. So the EXIF Info may not be available] For example one of them were taken [or a better example cellphone screenshot created] and uploaded on 1/1/2016. I downloaded it from the on-line album on 11/1/2017. When this jpeg file is listed in Win7 file explorer’s “details” view, under “date” column it is showing 1/1/2016. When I try to use Python to extract the creation date info, all three ways (st_atime, st_mtime, st_ctime) gave me 11/1/2017. I then right click the file and view its property, there “created”, “modified”, and “accessed” all pointed to 11/1/2017.

I am wondering if there is still a Python way to get the original creation date, i.e. 1/1/2016, from this file? On my windows screen I clearly see that date "1/1/2016" Why I could not retrieve it? That's thing really drives me to ask this question

Thank you!

LarryZ
  • 107
  • 2
  • 11
  • Your file has been created at that date. What you want is extract the date a photo was taken. So you need to extract the dates from the jpeg. I would recommend rephrasing your question. – mrCarnivore Dec 04 '17 at 17:46
  • 1
    You probably want to extract the EXIF data. Take a look at [this question](https://stackoverflow.com/questions/23064549/get-date-and-time-when-photo-was-taken-from-exif-data-using-pil) – EsotericVoid Dec 04 '17 at 17:48
  • Possible duplicate of [Get date and time when photo was taken from EXIF data using PIL](https://stackoverflow.com/questions/23064549/get-date-and-time-when-photo-was-taken-from-exif-data-using-pil) – tripleee Dec 04 '17 at 18:03
  • Thank you for your comments. I edited my question above. EXIF may not be relevant for my issue. – LarryZ Dec 04 '17 at 18:45

1 Answers1

0

You've merged some dates, so let's clarify which one you want. Consider this sequence:

  1. photographer (perhaps you) takes photo on 04 Jan;

  2. uploads to photographer's computer on 05 Jan;

  3. uploads to on-line album on 07 Jan.

  4. You find the file on 09 Jan and download to your album.

Now, which date do you want to extract? BTW, the 05 Jan date is almost certainly unavailable, unless you have access to the photographer's disk.

The 04 Jan date is available as shown in the link @EsotericVoid gave you; in that case, we should remove this question as a duplicate.

09 Jan is already available to you -- as you've lamented. :-)

For 07 Jan, you'll need to look up how to preserve dates in whatever download command you're using; most have an option that will keep the dates from the file source (creation, modification, and access).


Update per OP's clarification

Understood: you need the original photo date. That will be recorded only in the original image file. Since you have different file formats, you'll need to write code that will first determine the format, and then extract the date per that particular format. You now have a link to the EXIF solution.

Prune
  • 76,765
  • 14
  • 60
  • 81
  • Thank you for your comments. I edited my question above. EXIF may not be relevant for my issue. I am looking for 04 Jan in your example. This could be a cellphone sreenshot. See my revised question for details. – LarryZ Dec 04 '17 at 18:47
  • Thanks @Prune. EXIF is the best solution. – LarryZ Dec 05 '17 at 17:06