date and time of image files

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
carambola
Posts: 3
Joined: Thu Feb 09, 2017 11:55 am

date and time of image files

Post by carambola » Thu Feb 09, 2017 12:10 pm

Hi all,
how can I gathers date and time metadata from the image files?
I need to retrieve the date a photo was created before importing it.
Any idea?
Thanks.

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 129
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: date and time of image files

Post by PBH » Fri Feb 10, 2017 3:36 am

Sorry I don't have time to explain more right now, but checkout the function for 'detailed files' or 'long files' in the dictionary.

It will give you all the data you need. :)

Link: https://livecode.com/resources/api/#liv ... ript/files

Paul

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: date and time of image files

Post by MaxV » Mon Feb 20, 2017 1:40 pm

EXIF library is here for you: https://github.com/angerangel/livecodeExif
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: date and time of image files

Post by jmburnod » Mon Feb 20, 2017 1:50 pm

Hi Max,
I use "detailed files" with a simple lineoffset (to get the target line) to do that.
from dictionary about "detailed files"
to obtain a date, time, name, ID, or list of files or folders with the greatest amount of available detail.
Here is a Richard's script
http://forums.livecode.com/viewtopic.ph ... 23#p151263
Best regards
Jean-Marc
https://alternatic.ch

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: date and time of image files

Post by MaxV » Thu Feb 23, 2017 6:41 pm

Please note that images may have an internal data structure called EXIF. The EXIF tags have a lot of informations, like creation date.
The operating systems has information about files, but only regarding the operation system itself; creation date is external to file, and is about the filesystem hierarchy.
So a copied file can have a newer creation date, because is new; on the contrary the EXIF datas remain unchanged even copied, because their are internal data of the image.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: date and time of image files

Post by jmburnod » Thu Feb 23, 2017 7:36 pm

Hi Max,
Thanks for share.
the EXIF datas remain unchanged even copied
Very interesting and it seems simple to use.
I'm impatient to use it for one script that check if an image exist in a folder (same data with different filename)
Best regards
Jean-Marc
https://alternatic.ch

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: date and time of image files

Post by MaxV » Fri Feb 24, 2017 3:04 pm

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: date and time of image files

Post by Simon Knight » Sun Dec 15, 2019 5:35 pm

Bump!

I stumbled across this thread and thought I would add the following system call that works on MacOS:

Code: Select all

put shell("mdls -raw -name kMDItemContentCreationDate '" &  tImageFileSpec & "'" ) into tMyVar 
Terminal describes the syntax:
usage: mdls [-name attr][-sdb] [-raw [-nullMarker markerString]] [-plist file] path
list the values of one or all the attributes of the specified file
-raw: don't print attribute names before values
-nullMarker: substitute this string for null attributes in raw mode
-plist: output attributes in XML format to file. Use - to write to stdout
option -plist is incompatible with options -raw, -nullMarker, and -name
example: mdls ~/Pictures/Birthday.jpg
example: mdls -name Keyword ~/Pictures/Birthday.jpg
Example output :
_kMDItemDisplayNameWithExtensions = "20191128_194059_Didcot_Joe_McNally_P1024114.RW2"
kMDItemAcquisitionMake = "Panasonic"
kMDItemAcquisitionModel = "DC-G9"
kMDItemBitsPerSample = 64
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2019-11-28 19:40:59 +0000
kMDItemContentCreationDate_Ranking = 2019-11-28 00:00:00 +0000
kMDItemContentModificationDate = 2019-11-28 19:40:59 +0000
kMDItemContentModificationDate_Ranking = 2019-11-28 00:00:00 +0000
kMDItemContentType = "com.panasonic.rw2-raw-image"
kMDItemContentTypeTree = (
"com.panasonic.rw2-raw-image",
"public.camera-raw-image",
"public.image",
"public.data",
"public.item",
"public.content"
)
kMDItemCreator = "Ver.1.2 "
kMDItemDateAdded = 2019-12-15 11:41:01 +0000
kMDItemDateAdded_Ranking = 2019-12-15 00:00:00 +0000
kMDItemDisplayName = "20191128_194059_Didcot_Joe_McNally_P1024114.RW2"
kMDItemDocumentIdentifier = 0
kMDItemEXIFVersion = "2.3.1"
kMDItemExposureMode = 0
kMDItemExposureProgram = 3
kMDItemExposureTimeSeconds = 0.06666666666666667
kMDItemFlashOnOff = 0
kMDItemFNumber = 1.4
kMDItemFocalLength = 25
kMDItemFocalLength35mm = 50
kMDItemFSContentChangeDate = 2019-12-15 11:41:01 +0000
kMDItemFSCreationDate = 2019-12-15 11:41:01 +0000
kMDItemFSCreatorCode = "ttxt"
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "20191128_194059_Didcot_Joe_McNally_P1024114.RW2"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 23960064
kMDItemFSTypeCode = "TEXT"
kMDItemHasAlphaChannel = 0
kMDItemInterestingDate_Ranking = 2019-11-28 00:00:00 +0000
kMDItemISOSpeed = 800
kMDItemKind = "Affinity Openable"
kMDItemLensModel = "LEICA DG SUMMILUX 25/F1.4 "
kMDItemLogicalSize = 23960064
kMDItemMeteringMode = 5
kMDItemOrientation = 0
kMDItemPhysicalSize = 23961600
kMDItemPixelCount = 20155392
kMDItemPixelHeight = 3888
kMDItemPixelWidth = 5184
kMDItemProfileName = "Display P3"
kMDItemRedEyeOnOff = 0
kMDItemWhiteBalance = 1
best wishes

Simon K.
best wishes
Skids

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: date and time of image files

Post by Klaus » Sun Dec 15, 2019 6:09 pm

Isn't macOS wonderful? :D

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: date and time of image files

Post by Simon Knight » Mon Dec 16, 2019 1:26 am

Yes but I'm still mad that I'm not allowed to see colour or custom icons in the Finder side bar grrrrrr!

best wishes
Simon K.
best wishes
Skids

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”