471,853 Members | 1,129 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

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

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
Nov 21 '05 #1
0 8160

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
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.