GetImageInfo

The GetImageInfo method retrieves extra information (Exif, IPTC) from JPEG image.

GetImageInfo vFileName[, vDataType]

Parameters

vFileName
Path to image file or safearray containing JPEG image data.

vDataType
Optional. Specifies type of extra-data to look for (image can contain several data types). Default value is 0. The following values are supported:
0 (default)Search for any data type. First found data will be processed.
1Search for EXIF data only.
2Search for IPTC data only.

Return value

Method returns an instance of ImageInfo object.
Example
This .VBS example prints information about camera model, containing in EXIF data
Set g = CreateObject("shotgraph.image")
file_name = "c:\files\image.jpg"
Set info = g.GetImageInfo(file_name,1)
Wscript.echo info("Model")

ImageInfo object

This object is returned by GetImageInfo method. Object represents collection of different image properties. This collection exists as a "key -- value" relationship in the ImageInfo object. You should know the key name to retrieve its value. Also you should know what that value means: EXIF can contain data of various types, both strings and numbers. In case if one key has several values, ImageInfo keeps such value as array of numbers. Rational values are also kept as arrays, because every rational value consists of two numbers. Therefore, in some cases you should check values using standard VB IsArray or similar function.
You can retrieve all keys containing in object: the ImageInfo supports standard VB For Each -- Next loop. The following example shows typical VB script retrieving complete EXIF information from image, handling all arrays:
Set g = CreateObject("shotgraph.image")
filename = "c:\images\ixus.jpg"
Set info = g.GetImageInfo(filename)
s = ""
for each key in info
	s = s & key & ": "
	if IsArray(info(key)) then
		ar = info(key)
		for j = 0 to UBound(ar)
			s = s & ar(j) & " "
		next
		s = s & Chr(13) & Chr(10)
	else
		s = s & info(key) & Chr(13) & Chr(10)
	end if
Next
Wscript.echo s

Description of every possible key lays out of this paper. You can find detailed explanation of values for the most keys on www.exif.org site.

Properties of ImageInfo object

Type Read-only. Contains type of retrieved data (1 - EXIF, 2 - IPTC).
ErrorCode Read-only. Contains 0 if there were no errors. Other possible values:
1 - file can not be opened
2 - file can not be recognized as valid JPEG
3 - no EXIF or IPTC data in file.
Count Read-only. Contains amount of retrieved keys.
Item("key") Read-only. Contains value of retrieved key. If there is no such key in the image, returns empty variable.