how to get Image Metadata

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

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

how to get Image Metadata

Post by palanolho » Wed Jun 04, 2014 8:11 pm

Hi everyone,

I'm doing an app that needs to manipulate images and for that, I would need to read some metadata from the image
ex: Resolution (dpi), size (kb), type (jpg,png,etc...), Creation date, etc....


Anyone know how can I do this?

Many thanks,
- Miguel

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: how to get Image Metadata

Post by Klaus » Wed Jun 04, 2014 9:58 pm

Hola Miguel,

I think on the Mac you can use the SHELL command SIPS to get these infos.
No idea about Windwos, sorry.


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Wed Jun 04, 2014 11:44 pm

Hi Miguel,

look at this:

http://runtime-revolution.278305.n4.nab ... l#a2309183

there is a link to a library that Alex Tweedly made in Livecode to access EXIF data.

Maybe that helps

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: how to get Image Metadata

Post by [-hh] » Thu Jun 05, 2014 6:10 pm

On Mac you could also use (the script of) the following stack. I add it for users that aren't customised to "shell"-things or need a ready made click-object for start.
EXIF_Mac.jpg
I used this script, it's all in the filename-field, recently in a project. It contains an applescript that gives you (some) available meta tags of the image file on MacOS X. The timestamps are not part of this info (selected by OS X), but these you can easily get by LC's "the detailed files". Or you extend, if you know how to, the applescript to get more info from "sips" (Klaus mentioned above, should be lowercase), see "man sips" in terminal. If this is for use in a project you have to add things like a check whether the file in the field (still) exists.
shiftLock happens

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

Re: how to get Image Metadata

Post by palanolho » Thu Jun 05, 2014 8:16 pm

Thanks everyone. I'll give a look to all the suggestions

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

Re: how to get Image Metadata

Post by palanolho » Fri Jun 06, 2014 7:41 pm

Hi,

I tried the Alex Tweedly stack but it does not generate any info for any of the images select.

Anyone has used this before? do you know what may be the problem ? (I'm using Win7 64bit in case that matters)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Fri Jun 06, 2014 8:55 pm

Hi Miguel,

I tried Alex Tweedly's stack before recommending it. On some images it only returned -2. Apparently those did not have EXIF information. On other images, e.g. from my Canon Ixus it reported a lot of stuff. Also for images from another Canon camera. This is on an Mac.

EXIF seems to be a bit complictated, since it is not uniformly handled by different sources.

I append an image that returns EXIF data for me.
took 26
Image ,Make,Canon,ASCII,122
Image ,Model,Canon DIGITAL IXUS 50,ASCII,128
Image ,Orientation,1,Short,42
Image ,XResolution,180/1,Ratio,150
Image ,YResolution,180/1,Ratio,158
Image ,ResolutionUnit,Pixels/Inch,Short,78
Image ,Software,Adobe Photoshop CS Macintosh,ASCII,166
Image ,DateTime,2007:08:09 13:22:44,ASCII,196
Image ,ExifOffset,216,Long,114
EXIF ,ExposureTime,1/640,Ratio,534
EXIF ,FNumber,28/5,Ratio,542
EXIF ,ExifVersion,0220,String,250
EXIF ,DateTimeOriginal,2007:07:24 15:34:06,ASCII,550
EXIF ,DateTimeDigitized,2007:07:24 15:34:06,ASCII,570
EXIF ,CompressedBitsPerPixel,5/1,Ratio,590
EXIF ,ShutterSpeedValue,149/16,Signed Ratio,598
EXIF ,ApertureValue,159/32,Ratio,606
EXIF ,ExposureBiasValue,0/1,Signed Ratio,614
EXIF ,MaxApertureValue,95/32,Ratio,622
EXIF ,MeteringMode,CenterWeightedAverage,Short,346
EXIF ,Flash,Off,Short,358
EXIF ,FocalLength,29/5,Ratio,630
EXIF ,FlashPixVersion,0100,String,382
EXIF ,ColorSpace,1,Short,394
EXIF ,ExifImageWidth,259,Long,406
EXIF ,ExifImageLength,195,Long,418
EXIF ,FocalPlaneXResolution,11520/1,Ratio,638
EXIF ,FocalPlaneYResolution,81000/7,Ratio,646
EXIF ,FocalPlaneResolutionUnit,2,Short,454
EXIF ,SensingMethod,2,Short,466
Skipping EXIF ,Tag a401
Skipping EXIF ,Tag a402
Skipping EXIF ,Tag a403
Skipping EXIF ,Tag a404
Skipping EXIF ,Tag a406
KInd regards

Bernd

I could retrieve above EXIF data from the image here when I drag-dropped it to my desktop and ran libEXIF 0.9 on it.
kircheganzKlein Kopie.jpg
kircheganzKlein Kopie.jpg (23.65 KiB) Viewed 11453 times

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

Re: how to get Image Metadata

Post by palanolho » Fri Jun 06, 2014 10:55 pm

I created some graphics on Illustrator and wanted to check the DPI but no information is returned :( (returns -2 on the code)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Sat Jun 07, 2014 12:39 am

Hi Miguel,

are you shure Illustrator does add EXIF data to the illustration?

Did the image I posted work for you? Could libEXIF extract the information?

Kind regards

Bernd

palanolho
Posts: 122
Joined: Sat Apr 27, 2013 11:40 pm

Re: how to get Image Metadata

Post by palanolho » Sat Jun 07, 2014 1:31 pm

you are right.

I just tested with your image (and some other that I found out) and I'm able to get infos. But my images don't have any info...

however, I found out another Weird stuff ....

If I open the stack on LC 6.6.0, it works with your image.
However, if I open the stack with LC v7.0.0-dp-5, I'm getting error on this line

Code: Select all

function exifDecodeIFD pIFD, pIFDName

        Line 195:
        put binaryDecode(t, lexifData, tJunk, tValues) into tJ
Any Ideas ??

Also, is there any other way to get the DPIs of an image

thanks,

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Sat Jun 07, 2014 6:58 pm

Hi Miguel,
However, if I open the stack with LC v7.0.0-dp-5, I'm getting error on this line
There is an entry about binaryDecode in the release notes that extends the function.
If that is the reason that libEXIF breaks or if binaryDecode itself is buggy I don't know.

This binary stuff is too complicated for me.

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: how to get Image Metadata

Post by [-hh] » Sun Jun 08, 2014 6:43 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:30 pm, edited 2 times in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Sun Jun 08, 2014 6:50 pm

Hi Hermann,

thanks for this very useful tip.

BTW apparently the EXIF information is larger than the image :)

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: how to get Image Metadata

Post by [-hh] » Sun Jun 08, 2014 7:55 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:30 pm, edited 1 time in total.
shiftLock happens

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to get Image Metadata

Post by bn » Sun Jun 08, 2014 8:22 pm

Hi Hermann,
is the indexing tag "wherefrom" (which holds the information of the download source location, the apple thought police write-protects this):
well, well. At times it is useful to know where a document comes from. E.g. when downloading a new version of Livecode my Apple asks me if I want to open that document.
I click "open" and all is fine.
Imagine some other source of a document that somehow got into your computer. Might not always be the trusted source from Scottland.

And as far as write protection of this information is concerned: there might be security reasons why it is write protected.

Also Geo-tagging is a mixed blessing. I agree. On the other hand if you use a mobile phone everybody and his dog knows where you are and where you have been.

How to handle all this data has not yet been worked out apparently.

Kind regards
Bernd

Post Reply