- Cannot get IIS pickup directory
- PayPal cpp_header_image vs cpp_logo_image vs image_url
- Modifying Exif Information Using ASP.NET
- sqldatasource throwing null reference exception
- Formatting ADO GetString
- Integrate PHPBB With PayPal Subscriptions
- Integrate A Website With Sage50
- Classic ASP Web Development
- url rewrite rule converter
- Error BC30002 usercontrol not defined
- paypal discount_rate_cart not being applied
- kindle screen test
- accessdatasource converting empty strings to null values
- paypal ipn returns invalid
- cannot manually edit applicationhost.config
- must declare the scalar variable
- classic asp and access not working on windows 2008 64bit
- asp.net page titles are blank
- sql to get totals for last six months
- white space being counted as a node
- cross page posting not working
- collection is read only exception
- PayPal sending incorrect carrier information
- paypal guest user notice
- classic asp dictionary not working
- IE8 not supporting innerHTML
- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
Modifying Exif Information Using ASP.NET
There are two main problems you'll encounter when trying to modify exif information using asp.net, the first is that the meta data that is part of the image is only referenced by id; and the second is that there is no constructor for the PropertyItem Class.
This can make it tricky to identify what you are trying to change and seemingly impossible to add new meta data to an image.
The easiest thing to do for the first problem is to iterate through all the PropertyItems and to see for yourself what is in each one.
Dim i As System.Drawing.Image
i = Drawing.Image.FromFile(Server.MapPath("~/test.jpg"))
For Each p As System.Drawing.Imaging.PropertyItem In i.PropertyItems
Response.Write(p.Id & " " & p.Type & " " & Text.Encoding.Default.GetString(p.Value) & "<br>")
This will list out all the properties a particular image has, here is an overview of what each type number is for:
- 1 = Specifies that Value is an array of bytes.
- 2 = Specifies that Value is a null-terminated ASCII string. If you set the type data member to ASCII type, you should set the Len property to the length of the string including the null terminator. For example, the string "Hello" would have a length of 6.
- 3 = Specifies that Value is an array of unsigned short (16-bit) integers.
- 4 = Specifies that Value is an array of unsigned long (32-bit) integers.
- 5 = Specifies that Value data member is an array of pairs of unsigned long integers. Each pair represents a fraction; the first integer is the numerator and the second integer is the denominator.
- 6 = Specifies that Value is an array of bytes that can hold values of any data type.
- 7 = Specifies that Value is an array of signed long (32-bit) integers.
- 10 = Specifies that Value is an array of pairs of signed long integers. Each pair represents a fraction; the first integer is the numerator and the second integer is the denominator.
This information and more detail can be found here. Perhaps the most important thing to note about those types is number 2 (which is the type that most image titles are stored as) - it's a null terminated string, so when setting a new value you need to include the null terminator character Chr(0), failure to do this can lead to some unpredictable and probably undesirable results.
The second problem is that there is no constructor for the PropertyItem class, so you have to get an existing item and use that as a sort of pseudo-constructor (not sure how you would handle an image that had no properties at all).
Dim str As String = "hello world"
Dim pi As Drawing.Imaging.PropertyItem = i.GetPropertyItem(270)
pi.Id = 1
pi.Value = Text.Encoding.Default.GetBytes(str & Chr(0))
pi.Len = Len(str) + 1
So in the above example we got the property with id 270, then changed the id and the value and reset the length based on the new value + the null terminator character. Even though a type 2 property is listed as being ASCII, you appear to be able to get away with passing in non-ASCII charactered by using the default text encoder. Another thing to note, is that it appears that you cannot always change the type of the property when you are creating a new one, so you may have to find an image that does have the property type you want to use, create a property item from that image, then effectively transfer a copy of it to another image...