ImageMan ActiveX
Using Image Attributes

Getting Attributes of a loaded image

After loading an image, the ImageAttributes property contains a collection of Attribute objects that contain the various attributes for the current page of the opened image. The attributes for each page may be different so when reading a multi page image its necessary to query the ImageAttributes property for each page.


The Attribute object contains information about each attribute returned from the file. The Attribute object's Value property is a variant which contains the Attribute value. The variant may contain a single value or an array so its important that an application look at the variant type in order to get the value(s).


In order to conserve memory, attributes that are very large are not loaded until accessed. A side effect of this behavior is that an Attribute can only be loaded while its original image is still in memory, so if you need to access an unloaded Attribute the original image must still be opened in the image control. The IsLoaded property returns a boolean value indicating if the attribute is already loaded. Querying the Value property will load the attribute.


ImageControl1.Picture = "c:\tiff.tif"


' Iterate thru the Image's attributes

For Each Attr in ImageControl1.ImageAttributes

' Attr.Value contains the Value of the Attribute

MyValue = Attr.Value

' Attr.Name contains the Name of the Attribute ie EXTENSION, etc.



Specifying Attributes of a Saved Image

Attributes are also used when saving images to specify image specific options such as compression, comments, etc. An Attributes collection can be created in code and the Add method used to add attributes to the collection. Once the attributes have been added the collection can be passed to the SaveAs method when the image is saved.


Dim Attrs As Attributes

' Create an Attributes collection with our options


Set Attrs = New IMActX80Ctl.Attributes


Attrs.Add "EXTENSION", "TIF", IMActX80Ctl.IMString

Attrs.Add "COMPRESS", "True", IMActX80Ctl.IMString

Attrs.Add "TIFF_COMPRESS", "GROUP3", IMActX80Ctl.IMString

Attrs.Add "TIFF_FILLORDER", 2, IMActX80Ctl.IMInt32


' Pass the Attributes colection to the SaveAs method

ImageControl1.SaveAs "doc.tif", Attrs


Standard Attributes

ImageMan defines a standard set of attributes which are common to all the supported image formats. Not all formats however, support all the common attributes.


The standard attributes are:


EXTENSION Specifies the 3 letter extension of the image format String
COMMENT  Image Comment stored in file String
COPYRIGHT Copyright Information String
AUTHOR Author of the image String
SOFTWARE Specifies the Software used to write the image String
TITLE    Image Title String
DESCRIPTION Description of Image String


The format specific image Attributes for each format are listed in the Image Format information in the Image Formats book.





© 2014 Data Techniques, Inc. All rights reserved.

Submit feedback on this topic