Image File Metadata accessibility?

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

WayPastInk
Posts: 11
Joined: Sat Oct 14, 2006 2:08 pm

Image File Metadata accessibility?

Post by WayPastInk » Tue May 06, 2008 3:49 am

Hi. I have been away from Revolution for a year or so and am just picking up with the current Studio version.

I need to integrate Revolution into the workflow of my art conservation laboratory.

One of the things I want to explore is what metadata which is entrained in a TIFF or PNG (I haven't actually explored PNG metadata but think this is the file type I may need to use) is accessible through Revolution to read, write to and to preserve?

We use Nikon digital cameras (D200) and keep both the raw Nikon format file but also TIFF versions along with jpeg thumbnails where we can tolerate the lossy format.

I appreciate any and all information. I do not expect to be able to work with the Nikon proprietary raw format but much information can be captured and used with more universal file formats.

Regards

Mark MacKenzie
Mark MacKenzie
Art Conservator
Alcalde, NM

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue May 06, 2008 10:40 am

If it's a public format (like png) then there's probably a rfc or similar defining document somewhere on the net. You can then find out what chunk of a file contains your meta data, and read that out. Most likely you'll need to use the binary stuff for that, so look up these entries in the docu:

binaryEncode function
binaryDecode function
bitOr operator
bitAnd operator
bitXOr operator
bitAnd operator
baseConvert function

Said all that, I think some metadata libraries have already been done, and are available on revNet or some homepage. I only know that Udi has made one for jpg (seems it can do tiff too), so maybe that one can give you hints about what to do for png's.
If that's all too complex for you, there's probably some command line or applescript you can hook into (this depends on the target platform(s) of course).
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Thu Nov 27, 2008 3:55 pm

Though it's an old post, I've the same problem: I have to retreive some basic data from JPEG files like size and resolution.

I tried UDI's getJpegPixelSize but it doesn't seem to work (it says my JPEG file is not JPEG because "Error : File is not JPEG (not found APPx)", though it's a JPEG!).

I also tried UDI's getExif14 but, of course, it only works with image containing EXIF data.

So, is anybody know how could I retreive size and resolution from a JPEG file. I know I should use rev ImageData and binary things but it's really out of my understanding.

Thanks for your help.

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Contact:

Post by Obleo » Thu Nov 27, 2008 10:00 pm

If your using this from Mac OS X, there are some shell scripts that are for metadata that may help. I am unsure what if any are available from windows. Maybe someone else would be kind enough to list them, if there are any.

mdls(1) Returns the values of all metadata attributes associated with the files provided.

How it could be used. I tested this in rev and work pretty good.

example from rev:

Code: Select all

put shell("mdls ~/Pitctures/myFile.tiff ") into fld "yourMetaDataField" 
Above in that example it did not render the text good in the code box. It looks like a slash, it not it's one of these ~

the mdls also allows to get just listed attributes using the " mdls -name theAttributeName yourfilepath/file"

example

Code: Select all

mdls -name kMDItemColorSpace ~/Pitctures/myFile.tiff
Some of the other associated commands, open the terminal and search there man pages for complete info.

mdfind(1) consults the central metadata store and returns a list
of files that match the given metadata query. The query can be a string
or a query expression.

mdimport(1) import file hierarchies into the metadata datastore.

mdcheckschema(1) validates the mdimporter schema files provided as arguments and indicates whether the schema could be successfully parsed.

Not sure if this helps or not.

Good luck.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Nov 28, 2008 1:02 am

Hi Zax,

You might want to check out ExifTools. I used this to create an XMP library for a client. Often, metadata is embedded in picture files as plain text or UTF8. It may be quite simple to read this text from the picture file.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Fri Nov 28, 2008 11:20 am

Thanks for your quick replies.

Unfortunately Obleo, I will have to use the soft from MacOSX *and* Windows (sorry, I should mention this point in my previous post).

Mark, could you give me some links for ExifTools (a quick Google search gave me many results concerning different ExifTools). In other hand, I'm not sure ExitTools could help me because you know all JPEG images doesn't always contain EXIF data.
Anyway, I'll try ExifTools as soon as I'll know where to download it.

Once again, thanks all for your help. This project is important for me (I already released a PHP version but now I have to release a standalone version).

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Nov 28, 2008 11:40 am

Hi Zax,

The first link in Google: http://www.sno.phy.queensu.ca/~phil/exiftool/

I haven't installed it btw. I include it with the standalone, in the externals folder, when use the complete path to the executable when calling it from the shell.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Fri Nov 28, 2008 3:21 pm

Huh ?

Mark, you make me feel like I'm a totally newbie ;)
Maybe that's what I am in fact because I don't understand how could I use ExifTool without installing the package (of course, I don't want to install this package).
To be honnest, I also encouter some problem understanding ExifTool's documentation and it's not only due to the fact english is not my native language.

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Sat Nov 29, 2008 7:12 pm

OK, I finally was able to retreive image date with ExifTool, but only when ExifTool is installed on my Mac.

Now, when I disinstall ExifTool and I try to add ExifTool as external in my rev stack, it says "/bin/sh: line 1: exiftool: command not found". At this time, my rev stack is still in development mode but I presume I don't have to make a standalone to have an external work.

I order to test, I wrote in the msg box "answer the externalFunctions of stack <MyStack> and it answers nothing (an empty string).

So I guess my problem came from declaring the external in my stack.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Nov 29, 2008 7:26 pm

Hi Zax,

The easiest way is probably to enter the entire path to the command line executable, instead of only its name.

put shell("<path to executable> exifCommands")

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Sun Nov 30, 2008 10:55 am

Mark wrote:The easiest way is probably to enter the entire path to the command line executable, instead of only its name.

put shell("<path to executable> exifCommands")
Yeah, it works!
Thank you very much for your help Mark, you save my life!... Well, at least my application :)

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Contact:

Post by Obleo » Sun Nov 30, 2008 1:37 pm

Zax wrote:Thanks for your quick replies.

Unfortunately Obleo, I will have to use the soft from MacOSX *and* Windows (sorry, I should mention this point in my previous post).

.
I did locate shell info for windows on metadata at http://msdn.microsoft.com/en-us/library/bb643802.aspx

After seeing that library mark posted in action. I would guess that would be the best option. As it built with rev stack ready to use.

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Mon Dec 01, 2008 10:35 am

Thanks Obleo, I will have a look at your link ASAP (I actually have tons of other work to do) and keep you informed here.

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Post by Zax » Mon Dec 08, 2008 4:04 pm

Hi, it's me again :?

I now encounter strange problem when writing the "put shell() command" with Windows (works with MacOS)

I tried:

1 - simple test

Code: Select all

put shell("C:/MyExifPath/exiftool") into fld "Test"
and it works (ExifTool returns infos)

2 - test with space in MyExifPath

Code: Select all

put shell(quote & "C:/My ExifPath/exiftool" & quote) into fld "Test"
and it still works (ExifTool still returns infos)

3 - test with space in MyExifPath and argument

Code: Select all

put shell(quote & "C:/My ExifPath/exiftool" & quote && "-filetype") into fld "Test"
and it still works (ExifTool returns "no file specified")

4 - test with space in MyExifPath and MyImagePath with space

Code: Select all

put shell(quote & "C:/My ExifPath/exiftool" & quote && quote & "C:/Path To My Image.jpg" & quote) into fld "Test"
This doesn't work with Windows (Windows says ""C:/Path" is not a valid command) but works with MacOS.
The strange thing that if I type

Code: Select all

"C:/My ExifPath/exiftool" "C:/Path To My Image.jpg"
in the windows console, it works.

This make me mad :(
Any idea?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Dec 08, 2008 4:19 pm

Hi Zax,

I know this can be very tricky. You might try the shortFilePath function, to replace the file paths you are currently using. This should avoid the space problem and is probably the easiest solution.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply