Image Creation Date

Hi,

I am building a program that connects to a server and lists the files in a specific folder. The user is then able to select any file and download it.
I use TCPSocket/Http protocol to connect.
I have 2 questions:

  1. If possible, How can I get the “Date Created” for each file?
  2. Currently, when the user downloads the file, a new “Date Created” is attributed to the file. How, if possible, can I maintain the original “Date Created” attribute?

I have looked everywhere in xojo documents but can’t seem to figure it out. Any help would be greatly appreciated. Thanks!

Kareem

Are you looking for the FILE date created? if so, look at the FOLDERITEM
if you are looking for the IMAGE creation date (ie. when a photograph was taken), you need access to the EXIF data

The files I am trying to access are saved on an SD card at the time the photo is taken
I access the files using a wifi connection, so I am thinking the folderitem method would work as it would be the same as the EXIF data. Is that correct?

It should be, but bear in mind the Folderitem date information is tied to the FILE and controlled by the computer operating system as it is moved, renamed, copied, etc etc. while the internal EXIF data is controlled (or at least set) by the Camera that took the photo.

Therefore the EXIF data will NOT change regardless of what goes on with the file (assuming of course you don’t purposely alter it, or change the file type to something that does not support EXIF), where the FOLDERITEM very easily could change.

Reading EXIF data is not directly supported by XOJO (or any other language), and usually requires some type of 3rd party tool

Yes I am aware of that.
Now to try and figure out how to implement folderitem with TCPsocket.

CGImageSource has the ability to obtain the image meta data as a NSCFDictionary, when using CGImageDestination to write a CGImage to disk, you can pass a NSCFDictionary along with the image data.

CIImage has a properties NSDictionary which contains the image meta data.

[quote=241877:@Kareem Danish]The files I am trying to access are saved on an SD card at the time the photo is taken
I access the files using a wifi connection, so I am thinking the folderitem method would work as it would be the same as the EXIF data. Is that correct?[/quote]

Exif is information embedded into the picture file. The file creation and modification date have no relationship with it.

Have a look here : http://www.sno.phy.queensu.ca/~phil/exiftool/index.html you can shell to that tool and get the actual Exif information.

[quote=241911:@Sam Rowlands]CGImageSource has the ability to obtain the image meta data as a NSCFDictionary, when using CGImageDestination to write a CGImage to disk, you can pass a NSCFDictionary along with the image data.

CIImage has a properties NSDictionary which contains the image meta data.[/quote]

Image Meta Data Suite was so great :slight_smile:

Ha ha… CGImageProperties was one of the nails in it’s coffin.

For all available EXIF data you can also use the standard OSX command mdls.
mdls /path/image.jpg

Oh, and you can also use -name.
So this: mdls -name kMDItemContentCreationDate /path/image.jpg
…gives you the date of when the photo was taken (if the camera stores EXIF data but I think most modern cameras do)

If you use MBS Plugin, we do have CGImageSourceMBS class to read the properties for Mac and GraphicMagick to read them cross platform. We also do have the XMP Plugin to read properties cross platform including the XMP metadata (and EXIF).
For Spotlight, we also have MDItemMBS class to get properties from the Spotlight database.

thank you all for your input!

mdls seemed promising but it doesn’t seem to work if my file is on a server, i.e the path is a url path. I suppose I need to download it first locally and then pass the shell command. Correct?
Is there a way to do it without having to download the file first? The reason I ask is because I want to populate my list with date of creation and then have the user pick the file they want to download.

Thanks,

Kareem

You mentioned you were using TCPSocket so I assumed you were talking to another App on the other end. In that case, the App on the other end needs to read the EXIF data.

If it’s a Http server and don’t want to download the image first, (I think) the closest you can get is to retrieve the headers only and look for the ‘if-modified-since’ -header.
Although the Http server can be configured differently (or the image isn’t served statically), by default, it should return the file system last-modified date/time in the if-modified-since headers in UTC.

If you really want to know when the photo was taken, IMHO the best thing to do read the EXIF data on the server side. Can’t you write a tiny App that runs on the server that does that?

Thanks Marco, I will look into the header option. Unfortunately I have no way of running an app on the server. I am accessing the data from the user’s SD card via Wifi. the SD card acts as the server and I can’t install anything on it.

mdls is part of the Spotlight framework and will only work for files on your machine that it has indexed (this does not include files within a bundle or package).

You might want to take a look at Apple Image Capture frameworks, they may already have done this for you.

Thanks Sam. I will also check into the image capture framework.

Thank you all for your help. I was able to get the information i needed using the httpsocket.getheaders method

dim filedate as string
dim urlsocket as New HTTPSocket
urlsocket.GetHeaders(url as string)
filedate = urlSocket.PageHeaders.Value(3) 'Not sure if index 3 always represents the file creation date but it worked in my case.
MsgBox(filedate)

No. It’s not always the 3rd. Better use something like this:

  Dim filedate As String
  Dim urlsocket As New HTTPSocket
  urlsocket.Yield = True
  
  Dim iHeaders As InternetHeaders
  
  iHeaders = urlsocket.GetHeaders("http://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",5)
  If iHeaders <> Nil Then
    filedate = iHeaders.Value("Last-Modified")
    MsgBox(filedate)
  End If

(And I mixed things up earlier btw. Sorry for that. The ‘if-modified-since’ -header can be used in a GET request to avoid downloading items you already have.)

Thanks for your reply.

I was running into some problems so this clarified it.