469,282 Members | 1,779 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Howto SET image metadata (Tiff, geotiff, exif tags)

I saw that VB .Net 2003 has some tools for easily reading metadata
information present in some TIFF and JPG files, eg.
----------------------------------------------------------------
....
Dim b As New Bitmap(OpenFileDialog1.FileName)
For Each p As System.Drawing.Imaging.PropertyItem In b.PropertyItems
' do something with
' p.Id
' p.Len
' p.Type
' p.Value
Next
----------------------------------------------------------------

And this works nicely, you can google for some code on the web that parses
out EXIF tags, TIFF tags etc.

Now how about WRITING tags ? Much messier !
Acc to docs, there is no constructor for the PropertyItem class, so where do
you get an instance ?
Microsofts answer: you STEAL it. From an existing tag:

----------------------------------------------------------------
....
Dim b As New Bitmap(OpenFileDialog1.FileName)

Dim prop As System.Drawing.Imaging.PropertyItem = image.PropertyItems(0) '
steal this instance
Dim bvalue() As Byte = {0, 1, 2, 3}
prop.Id = 34264 '//set the id (Tag Number)
prop.Len = 4 'set the length
prop.Type = 2'//set the type (datatype)
prop.Value = bvalue '//set the value
image.SetPropertyItem(prop) '//apply the property to the image
----------------------------------------------------------------

I assume this will add rather than replace the existing (stolen)
propertyitem, as long as a different Id is used.
But what if I start with an image from scratch, eg.
----------------------------------------------------------------
Dim image As New Bitmap(200, 200,
System.Drawing.Imaging.PixelFormat.Format32bppPArg b)
....draw stuff into image
....now how to add a PropertyItem to image ????
----------------------------------------------------------------
I need to add GeoTIFF tags to bitmaps created from scratch in VB .net
....whats the recommended route ?

Thanks in advance
Robert
Nov 21 '05 #1
0 7971

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Phil Powell | last post: by
14 posts views Thread by Steve K. | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.